https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81260
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2017-06-30 CC| |msebor at gcc dot gnu.org Ever confirmed|0 |1 Known to fail| |5.3.0, 6.3.0, 7.1.0, 8.0 --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirmed with the smaller test case below and all of 5.x, 6.x, 7.x, and 8.0. The expected warning is issued when the class is empty (in g()) but not otherwise. Interestingly, Clang only diagnoses the first call to f() in both functions, maybe because it "forgets" about the temporary as it passes through the implicitly generate copy assignment operator in the second call. $ cat t.C && gcc -S -Wall -Wextra -Wpedantic t.C void f (void*); struct A { A (int); }; struct B { B (int); int i; }; void g () { f (&(A (1))); f (&(A (1) = 1)); } void h () { f (&(B (1))); f (&(B (1) = 1)); } t.C: In function ‘void g()’: t.C:13:13: error: taking address of temporary [-fpermissive] f (&(A (1))); ^ t.C:14:17: error: taking address of temporary [-fpermissive] f (&(A (1) = 1)); ^ t.C: In function ‘void h()’: t.C:19:13: error: taking address of temporary [-fpermissive] f (&(B (1))); ^