<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - `__has_feature(cxx_exceptions)` has different value in automatic crash reproducer than in original input code, making it unusable with eg absl code"
   href="https://bugs.llvm.org/show_bug.cgi?id=52007">52007</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>`__has_feature(cxx_exceptions)` has different value in automatic crash reproducer than in original input code, making it unusable with eg absl code
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Driver
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ 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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>