Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ ../cpla.sh p178-2
- $ clang++ p178-2.cpp -std=c++03 -Wall
- p178-2.cpp:12:1: error: declaration of anonymous struct must be a definition
- struct [[nodiscard]] error_info { /*...*/ };
- ^
- p178-2.cpp:12:1: warning: declaration does not declare anything [-Wmissing-declarations]
- p178-2.cpp:14:1: error: unknown type name 'error_info'
- error_info ei;
- ^
- p178-2.cpp:15:1: error: unknown type name 'error_info'
- error_info & e=ei;
- ^
- p178-2.cpp:17:1: error: unknown type name 'error_info'
- error_info enable_missile_safety_mode(){return ei;}
- ^
- p178-2.cpp:24:1: error: unknown type name 'error_info'
- error_info &foo(){return e;}
- ^
- 1 warning and 5 errors generated.
- $ clang++ p199.cpp -std=c++2a -Wall
- p178-2.cpp:20:1: warning: ignoring return value of function declared with 'nodiscard' attribute
- [-Wunused-result]
- enable_missile_safety_mode(); // warning encouraged
- ^~~~~~~~~~~~~~~~~~~~~~~~~~
- 1 warning generated.
- f(){foo();}
- testmissiles(){enable_missile_safety_mode();launch_missiles();}
- C++N4741(97)10.6.7 Nodiscard attribute [dcl.attr.nodiscard]p178-2.cpp
- $ g++-8 p199.cpp -std=c++03 -Wall
- p199.cpp:12:20: warning: c++11 attributes only available with -std=c++11 or -std=gnu++11
- struct [[nodiscard]] error_info { /*...*/ };
- ^
- p178-2.cpp: In function 'void test_missiles()':
- p199.cpp:20:28: warning: ignoring returned value of type 'error_info', declared with attribute nodiscard [-Wunused-result]
- enable_missile_safety_mode(); // warning encouraged
- ^
- p199.cpp:17:12: note: in call to 'error_info enable_missile_safety_mode()', declared here
- error_info enable_missile_safety_mode(){return ei;}
- ^~~~~~~~~~~~~~~~~~~~~~~~~~
- p178-2.cpp:12:22: note: 'error_info' declared here
- struct [[nodiscard]] error_info { /*...*/ };
- ^~~~~~~~~~
- f(){foo();}
- testmissiles(){enable_missile_safety_mode();launch_missiles();}
- C++N4741(97)10.6.7 Nodiscard attribute [dcl.attr.nodiscard]p178-2.cpp
- $ g++-8 p178-2.cpp -std=c++2a -Wall
- p178-2.cpp: In function 'void test_missiles()':
- p178-2.cpp:20:28: warning: ignoring returned value of type 'error_info', declared with attribute nodiscard [-Wunused-result]
- enable_missile_safety_mode(); // warning encouraged
- ^
- p178-2.cpp:17:12: note: in call to 'error_info enable_missile_safety_mode()', declared here
- error_info enable_missile_safety_mode(){return ei;}
- ^~~~~~~~~~~~~~~~~~~~~~~~~~
- p178-2.cpp:12:22: note: 'error_info' declared here
- struct [[nodiscard]] error_info { /*...*/ };
- ^~~~~~~~~~
- f(){foo();}
- testmissiles(){enable_missile_safety_mode();launch_missiles();}
- C++N4741(97)10.6.7 Nodiscard attribute [dcl.attr.nodiscard]p178-2.cpp
Add Comment
Please, Sign In to add comment