[llvm-bugs] [Bug 52007] New: `__has_feature(cxx_exceptions)` has different value in automatic crash reproducer than in original input code, making it unusable with eg absl code

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 28 18:25:55 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52007

            Bug ID: 52007
           Summary: `__has_feature(cxx_exceptions)` has different value in
                    automatic crash reproducer than in original input
                    code, making it unusable with eg absl code
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

$ cat feat.cc 
#if  __has_feature(cxx_exceptions)
int a = 1;
#else
int a = 0;
#endif
#pragma clang __debug crash

When preprocessing, this prints:

$ out/gn/bin/clang-cl -c feat.cc -fcrash-diagnostics-dir=. /E
# 1 "feat.cc"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 369 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "feat.cc" 2
int a = 0;PLEASE submit a bug report


So it takes the else branch. But the crash file written by the driver looks
like:

$ cat feat-c41bad.cpp 
# 1 "<built-in>"
# 1 "feat.cc"
#if 0 /* disabled by -frewrite-includes */
#if  __has_feature(cxx_exceptions)
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 2 "feat.cc"
int a = 1;
#else
# 4 "feat.cc"
int a = 0;
#endif
# 6 "feat.cc"
#pragma clang __debug crash


So that takes the `#if` branch.


That's kind of bad!

And it's a problem in practice because absl tries to use `try` if `
__has_feature(cxx_exceptions)`, so the crash reproducer generated for code
containing absl then fails to compile and can't reproduce anything.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210929/7ecd3c32/attachment.html>


More information about the llvm-bugs mailing list