[llvm-bugs] [Bug 45520] New: 'nodiscard' can be applied to function pointers
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Apr 13 14:44:48 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45520
Bug ID: 45520
Summary: 'nodiscard' can be applied to function pointers
Product: clang
Version: 10.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++17
Assignee: unassignedclangbugs at nondot.org
Reporter: tiagomacarios 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
clang, gcc, and cl disagree on the diagnostics for the code below:
https://godbolt.org/z/-zaSRh
[[nodiscard]] bool (*f)();
void _(){
f();
}
clang:
<source>:4:3: warning: ignoring return value of function declared with
'nodiscard' attribute [-Wunused-result]
f();
^
1 warning generated.
Compiler returned: 0
gcc:
<source>:1:25: warning: 'nodiscard' attribute can only be applied to functions
or to class or enumeration types [-Wattributes]
1 | [[nodiscard]] bool (*f)();
| ^
Compiler returned: 0
cl:
example.cpp
Compiler returned: 0
Looking at the standard I would think that gcc's behavior is correct?
http://eel.is/c++draft/dcl.attr.nodiscard#1.sentence-1
"The attribute-token nodiscard may be applied to the declarator-id in a
function declaration or to the declaration of a class or enumeration."
--
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/20200413/c4f50113/attachment.html>
More information about the llvm-bugs
mailing list