<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 - No `-std=c2x` identification-macros at compile-time."
href="https://bugs.llvm.org/show_bug.cgi?id=50273">50273</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>No `-std=c2x` identification-macros at compile-time.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>12.0
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C2x
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ipaldesse@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24842" name="attach_24842" title="no_c2x_identify_code_example">attachment 24842</a> <a href="attachment.cgi?id=24842&action=edit" title="no_c2x_identify_code_example">[details]</a></span>
no_c2x_identify_code_example
Looks like `clang-12` has no macros at compile-time for `-std=c2x`
identification, or at least for it's features. Here's an example of what I
mean:
<span class="quote">> cat cxx.c</span >
#if __has_extension(cxx_attributes) || __has_feature(cxx_attributes)
# define is_cpp_attr 1
#else
# define is_cpp_attr 0
#endif
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
# define is_c2x_support 1
#else
# define is_c2x_support 0
#endif
int main(void) {
#if is_cpp_attr || is_c2x_support
"c2x works";
#else
"has no c2x definition support";
#endif
}
<span class="quote">> clang-12 -std=c2x -dM -E cxx.c | grep "is_c" </span >
#define is_c2x_support 0
#define is_cpp_attr 0
<span class="quote">> cp cxx.c cxx.cpp
> clang++-12 -dM -E cxx.cpp | grep "is_c"</span >
#define is_c2x_support 0
#define is_cpp_attr 1
Because of this bug the next C-code, compiled with `clang -std=c2x`, will not
never work with C++11-style attributes:
#if __is_cpp_attr__
# define libsalloc_attr_transparent [[gnu::transparent_union]] // -std=c2x
will not change anything
#else
# if __has_attribute(transparent_union)
# define libsalloc_attr_transparent __attribute__((transparent_union))
# else
# define libsalloc_attr_transparent
# endif
#endif
Thanks.</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>