http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57573
Bug ID: 57573 Summary: [C++1y] bogus "taking address of temporary" error Product: gcc Version: 4.9.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org struct A { }; struct B { A a; }; void f(A*) { } template<class T> void g() { B b; f(&(b.a)); } This compiles OK with -std=c++98 or -std=c++11 but not -std=c++1y: $ g++11 f.cc -std=c++1y -c f.cc: In function ‘void g()’: f.cc:10:10: error: taking address of temporary [-fpermissive] f(&(b.a)); ^ It also compiles OK if g() is not a template. This causes an error in <mutex> in C++1y mode: /home/redi/gcc/4.x/include/c++/4.9.0/mutex: In function ‘void std::call_once(std::once_flag&, _Callable&&, _Args&& ...)’: /home/redi/gcc/4.x/include/c++/4.9.0/mutex:786:48: error: lvalue required as unary ‘&’ operand int __e = __gthread_once(&(__once._M_once), &__once_proxy); ^ I don't know why those parentheses are there in <mutex> so they just can be removed to fix the problem.