<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/112152>112152</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Macro expansion of # pragma directive differs from GCC.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mrolle45
      </td>
    </tr>
</table>

<pre>
    Clang expands macros in the remainder of a # pragma, but gcc does not.

This is important because the pragma will be interpreted by a downstream compiler (if clang is used as a front end), or written to a .i file with the -E command line switch.  In either case, there is no way for macros to be expanded afterward.  Hence, clang and gcc will produce different results.

Macro expansion is neither required nor prohibited in the C or C++ standard, so it would fall into the category of implementation-defined behavior.

clang is advertised as a complete replacement for gcc.  Therefore, in order to keep true to this statement, clang SHOULD NOT expand macros.

I used gcc version 10 to test this. If gcc should change this behavior in a later version (which I consider unlikely), then clang should make a similar change, and provide a command line option to specify which behavior the user wants to use.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxclM1u6zYQhZ-G3gwiyPRP5IUWN0nTG6DtXTR9AJocSdNQpDocWfXbF6SVpLmAYcOQeM7Hc4Y0KVEfEFt1eFCHp42ZZYjcjhy9x_1hc47u2j56E3rAfycTXILRWI4JKIAMCIyjoeCQIXZgQOkdTGz60Sj9COdZoLcWXMQEIUql6idVf7t9vw6UIH_GKbKYIHBGa-aERfcmAgt5D2cECoI8MQo6OF_BgItLSMJoRrBxnMgjg9INdWALLSWYEzowCQx0HIMABqf0KXNFhoVJBANIBAMVQUceYSEZivvdL1l1NMGBp4CQFhI7VAAvAZBkQAZrEmat_AezXYiwmCt0kd8jkpjRb7lllE6QF8OuAviOwZblN9pslIMq2504utkiOOo6ZAwCjGn2kr7E93v2uIkniqEQrGiM_8zE6CBEzmoDnSkHt1ZW9v-o9IPSD5DEBGfYZZYUgQSWOHsHnfE-px7LEmsE-8jXXDKNk8cRgxihGO4cdhRyKziYC0X-AvnRhXEXZKGPRnJnHiXPz-SNLXolut7aCuA1h9pFLhFRgMh5wiTCG-IEwjNCIaOUNyBl-Weaf37_8ddvT_DHj9c1_LWQL2gvt_nIqV-QS4TbuqhikiJdwUtXnqehRGIHE3q8ub7vNsMZ8EaQP2SUbpaB7AAvYGNIlNHn4OkN_XUdQBkwrLCr-GjeEAwkGskbXr3yqxl_4nghh7fcPqcyTrmBzJwmtNRd4eb7AZermxMyLCZImcc54ZrCxrU7d9qdzAbb7b1umuNxVzebob03Td0cjvbedO5g97bB4-l0cIe6adCdum5Dra71fltv93W9a3RTYXfE5nQ2-rhtjnZn1b7Ot4KvvL-MVeR-QynN2G63envQG2_O6FO5cbQOuEB5qrTOFxC3edHdee6T2teekqRPGSHx2P48-bH737UDjhit0OX9_KR8-kf49fGx2szs20FkSmr3TelnpZ97kmE-VzaOSj9nn_XnbuL4N1pR-rnQJaWfV_xLq_8LAAD__9M6xqM">