<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Undefining __GNUC__ or setting __GNUC__ to 1 breaks libc++"
   href="https://llvm.org/bugs/show_bug.cgi?id=30446">30446</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Undefining __GNUC__ or setting __GNUC__ to 1 breaks libc++
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>noloader@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We are trying to stop Clang from pretending to be other compilers. We have
specific code paths for both LLVM and Apple Clang, and the constant application
of work-arounds because Clang cannot consume the same programs as GCC is
becoming tiresome.

When we add the following to our code it completely breaks things. Originally
we tried undefining __GNUC__ to get it out of "GCC code paths". Then we tried
setting it to 1 to give it a "minimal GCC configuration". Then we tried setting
it to 3 to obtain the "minimal GCC configuration".

Setting __GNUC__ to 4 gets Clang out of GCC 4.0.1, 4.1 and 4.2 code paths. That
allows some of the SSE3 and SSSE3 stuff to compile as expected. GCC added SSE3
support at GCC 4.1, but Clang fails to compile it.

Test program:

$ cat test.cxx 
#if defined(__GNUC__) && defined(__clang__)
# undef __GNUC__
# undef __GNUC_MINOR__
# undef __GNUC_PATCHLEVEL__
# define __GNUC__ 1
#endif

#include <string>
int main(int argc, char* argv[])
{
  return 0;
}

Results:

$ c++ -DNDEBUG -g2 -O2 -stdlib=libc++ test.cxx -o test.exe
In file included from test.cxx:8:
In file included from /usr/bin/../lib/c++/v1/string:435:
In file included from /usr/bin/../lib/c++/v1/iosfwd:90:
In file included from /usr/include/wchar.h:70:
In file included from /usr/include/_types.h:27:
In file included from /usr/include/sys/_types.h:32:
/usr/include/sys/cdefs.h:81:2: warning: "Unsupported compiler detected"
      [-W#warnings]
#warning "Unsupported compiler detected"
 ^
1 warning generated.</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>