[llvm-bugs] [Bug 43743] New: clang-6: __has_cpp_attribute(nodiscard) == true with -std=c++14, but warns about usage with -pedantic
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Oct 21 06:10:25 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43743
Bug ID: 43743
Summary: clang-6: __has_cpp_attribute(nodiscard) == true with
-std=c++14, but warns about usage with -pedantic
Product: clang
Version: 6.0
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: hans.dembinski at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
__has_cpp_attribute(nodiscard) wrongly returns true when `-std=c++14` is
selected. The expected behavior is to return false in this case.
This is a problem for libraries which conditionally use [[nodiscard]] when it
is available but also want to compile cleanly with -pedantic -Werror. This is
the case for some Boost libraries. clang-6 errors with `-std=c++14 -pedantic
-Werror` when [[nodiscard]] is used - although its detection macro indicates
its availability. This is inconsistent.
Demo on Godbolt:
https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,lang:c%2B%2B,source:'int+main()+%7B%0A++++//+nodiscard+is+C%2B%2B17,+but+accepted+with+-std%3Dc%2B%2B14%0A++++static_assert(__has_cpp_attribute(nodiscard),+%22%22)%3B%0A++++struct+%5B%5Bnodiscard%5D%5D+foo+%7B%7D%3B%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:clang600,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'1',trim:'1'),lang:c%2B%2B,libs:!((name:boost,ver:'171')),options:'-std%3Dc%2B%2B14+-pedantic+-Werror',source:1),l:'5',n:'0',o:'x86-64+clang+6.0.0+(Editor+%231,+Compiler+%231)+C%2B%2B',t:'0')),k:50,l:'4',m:71.99297629499561,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compiler:1,editor:1,wrap:'1'),l:'5',n:'0',o:'%231+with+x86-64+clang+6.0.0',t:'0')),header:(),l:'4',m:28.007023705004386,n:'0',o:'',s:0,t:'0')),k:50,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191021/02e4f921/attachment.html>
More information about the llvm-bugs
mailing list