<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 - __VA_OPT__ is only supported by Clang's preprocessor in C++2a mode but GCC seems to support it in all language modes"
   href="https://bugs.llvm.org/show_bug.cgi?id=40665">40665</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__VA_OPT__ is only supported by Clang's preprocessor in C++2a mode but GCC seems to support it in all language modes
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dan@su-root.co.uk
          </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>The attached program can be compiled by GCC 8.2.1 in various language modes

```
gcc -x c -std=gnu89 varargs.c
gcc -x c -std=gnu99 varargs.c
gcc -x c -std=gnu11 varargs.c
gcc -x c -std=gnu89 varargs.c
gcc -x c -std=gnu99 varargs.c
gcc -x c -std=gnu11 varargs.c
g++ -x c++ -std=c++98 varargs.c
g++ -x c++ -std=c++11 varargs.c
g++ -x c++ -std=c++14 varargs.c
g++ -x c++ -std=c++17 varargs.c
g++ -x c++ -std=c++2a varargs.c
g++ -x c++ -std=gnu++98 varargs.c
g++ -x c++ -std=gnu++11 varargs.c
g++ -x c++ -std=gnu++14 varargs.c
g++ -x c++ -std=gnu++17 varargs.c
g++ -x c++ -std=gnu++2a varargs.c
```

but Clang fails to compile it because the `__VA_OPT__()` macro does not get
expanded for all of the above language variants except for `c++2a` and
`gnu++2a`.

I believe `__VA_OPT_()` is a C++2a feature so Clang is probably more correct
here.

However according to <a href="https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html">https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html</a>
`__VA_OPT_()` is supposed to be available for GNU C and GNU C++ too so we
probably ought to enable it when we are compiling for the GNU language variants
`-std=gnu*`.

The fact that GCC allows `__VA_OPT__()` in non-GNU language variants that isn't
`c++2a` seems like a bug but I am not currently in a position to report it.</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>