https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77496
--- Comment #3 from Bernd Edlinger <bernd.edlinger at hotmail dot de> --- The "correct" test case emits two nearly identical -Wpedantic warnings: One when the template is parsed, and one when the template is instantiated. The second one is unnecessary, IMHO. template <class x> class z : x { public: bool zz () { return false; } int f () { return zz () ? : 1; } // { dg-warning "omitted middle operand" } }; class t { }; int main () { z<t> x; return x.f (); } g++ -Wpedantic pr77496.C pr77496.C: In member function 'int z<x>::f()': pr77496.C:9:29: warning: ISO C++ does not allow ?: with omitted middle operand [-Wpedantic] int f () { return zz () ? : 1; } // { dg-warning "omitted middle operand" } ^ pr77496.C: In instantiation of 'int z<x>::f() [with x = t]': pr77496.C:20:15: required from here pr77496.C:9:27: warning: ISO C++ forbids omitting the middle term of a ?: expression [-Wpedantic] int f () { return zz () ? : 1; } // { dg-warning "omitted middle operand" } ^