[Bug c++/100210] New: [[nodiscard]] constructor causes warning on arm-linux-gnueabihf
georg.schwab at emocean dot io
gcc-bugzilla@gcc.gnu.org
Thu Apr 22 13:12:43 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100210
Bug ID: 100210
Summary: [[nodiscard]] constructor causes warning on
arm-linux-gnueabihf
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: georg.schwab at emocean dot io
Target Milestone: ---
Target: arm-linux-gnueabihf
Created attachment 50655
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50655&action=edit
offending code
The code below causes a warning under arm-linux-gnueabihf when using
-Wunused-result. Under x86_64-linux-gnu and aarch64-linux-gnu, the code
compiles without warnings.
(Tested on Ubuntu 20.04.1 LTS for x86_64)
Offending Code:
===============
struct X
{
[[nodiscard]] X(int);
};
void t()
{
X x(0);
}
Command Line and Output:
========================
$ arm-linux-gnueabihf-g++-10 -c -Wunused-result nodiscard-constructor.cpp
nodiscard-constructor.cpp: In function ‘void t()’:
nodiscard-constructor.cpp:8:7: warning: ignoring return value of ‘X::X(int)’,
declared with attribute ‘nodiscard’ [-Wunused-result]
8 | X x(0);
| ^
nodiscard-constructor.cpp:3:16: note: declared here
3 | [[nodiscard]] X(int);
| ^
nodiscard-constructor.cpp:8:7: warning: ignoring return value of ‘X::X(int)’,
declared with attribute ‘nodiscard’ [-Wunused-result]
8 | X x(0);
| ^
nodiscard-constructor.cpp:3:16: note: declared here
3 | [[nodiscard]] X(int);
|
More information about the Gcc-bugs
mailing list