https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89870
Bug ID: 89870 Summary: C++ suggest header for abort() Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jg at jguk dot org Target Milestone: --- trunk gcc can suggest the missing #include <stdlib.h> header if the following code is compiled as C. trunk g++ does not suggest missing #include <cstdlib> (C++ style) header in the following code compiled as C++. Can the C++ header suggestion pick this up somehow? int main() { abort(); } Tested on godbolt trunk today [C++] #1 with x86-64 gcc (trunk) <source>: In function 'int main()': <source>:3:5: error: 'abort' was not declared in this scope 3 | abort(); | ^~~~~ Compiler returned: 1 [C] #1 with x86-64 gcc (trunk) <source>: In function 'main': <source>:3:5: warning: implicit declaration of function 'abort' [-Wimplicit-function-declaration] 3 | abort(); | ^~~~~ <source>:3:5: warning: incompatible implicit declaration of built-in function 'abort' <source>:1:1: note: include '<stdlib.h>' or provide a declaration of 'abort' +++ |+#include <stdlib.h> 1 | int main() Compiler returned: 0