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: unassignedclangb...@nondot.org
          Reporter: nicolaswe...@gmx.de
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to