https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86177
--- Comment #1 from Jonny Grant <jg at jguk dot org> --- If g++ compiles both main.cpp and main2.cpp at the same time (ie no separate obj file stage) it also doesn't give the expected warning. jonny@asus:~/code$ g++-8 -O2 -Wall -Wextra -Wnull-dereference -Wpedantic -o main main2.cpp main.cpp jonny@asus:~/code$