<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 - reconsider when we automatically define _GNU_SOURCE"
   href="https://bugs.llvm.org/show_bug.cgi?id=35141">35141</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>reconsider when we automatically define _GNU_SOURCE
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>richard-llvm@metafoo.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Currently, Clang follows GCC in automatically defining _GNU_SOURCE when
compiling C++ on a glibc platform. We should revisit this.


We need _GNU_SOURCE for the following:

1) GNU extensions used by user code.
2) GNU extensions used in the implementation of libstdc++.
3) C99 and C11 extensions.

For case #1, we could ask the user to provide -D_GNU_SOURCE explicitly on the
command line when compiling C++, as they are required to when compiling C. This
would break compatibility with GCC, though, so isn't obviously a win, but would
equally allow us to accept valid code that -D_GNU_SOURCE rejects. Perhaps a
separate flag for controlling this would be best.

For case #2, we may be able to get away with a smaller set of extensions. In
particular, _ISOC99_SOURCE and _ISOC11_SOURCE appear to be sufficient to
support most or all of libstdc++, and also appear to be sufficient for libc++.

Case #3 just needs _ISOC99_SOURCE / _ISOC11_SOURCE. (glibc should really be
able to figure this one out for itself based on the value of __cplusplus, but
it doesn't seem to do so today.)


At the very least, we should define _ISOCxx_SOURCE automatically based on the
C++ language mode, so that users need only pass -U_GNU_SOURCE to get a working
C++ compilation without the extensions. (Unfortunately, even this is not easy
right now, as the code adding this define is scattered throughout our target
definitions.)</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>