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

    <tr>
        <th>Summary</th>
        <td>
            Other differences with GCC involving consecutive ## tokens.  See #113236.
        </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>
    When defining NDEBUG in a Debug build of clang, I found some important differences with GCC.

Input 
``` c
#define FOO(a,b,c) ;b########c,b##########c,a########a,a##########a,\
 b##a##a##a##c,b##a##a##a##a##c,a##a##a##a##a,a##a##a##a##a##a
FOO(,y,z)
FOO(x,y,z)
```

clang -E produces
``` c
 ;y####z,y####z,##,##, yz,yz,,
;y####z,y####z,x####x,x####x, yxxxz,yxxxxz,xxxxx,xxxxxx
```
gcc -E produces
``` c
;yz,yz,,, yz,yz,,
;yz,yz,xx,xx, yxxxz,yxxxxz,xxxxx,xxxxxx
```

It is apparent (without reading the actual GCC source code) that when it sees `####`, this is treated exactly the same as `##a##` with `a` being an empty parameter.

On the other hand, clang treats the second `##` as an ordinary token.

### Suggestion
When a parameter is empty, it would be simpler (and less error-prone) to make an actual placeholder token and follow the rules in the C standard for pasting.  Likewise, consecutive `##` tokens should be separated by a placeholder.  The only special cases you need are for the actual pasting of two tokens and the removal of placeholders later.  A placeholder only remains after pasting in a case like `a##a` or `a##a##a`.

Similarly, use a placeholder for `__VA_OPT__( tokens... )` when `__VA_ARGS__` is empty.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU2P4zYM_TXKhdjAkfN58GE2s1ksUHSKzrY9BrTNxOrIkiHJSby_vqDsfGEy7aJAENmkRL73SFrovdobokzMPovZ8wjbUFmX1c5qTdPZKLdll_1VkYGSdsoos4dfn798_uMrKAMIz5S3e8hbpUuwOyg0mr2Qa_gG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