https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> --- (In reply to Jason Merrill from comment #5) > (In reply to Jakub Jelinek from comment #2) > > Given: > > class C { > > static const long b = 0; > > static const unsigned c = (b); > > }; > > class D { > > static const long b = 0; > > static const unsigned c = b; > > }; > > template <class> class A { > > static const long b = 0; > > static const unsigned c = (b); > > }; > > template <class> class B { > > static const long b = 0; > > static const unsigned c = b; > > }; > > > > we only reject the A case. > > For D and B there is just INTEGER_CST, and for C and A we have: > > (unsigned int) (long int) *(const long int &) &b > > because of the parens. > > The reason why it is accepted outside of template and not inside of it is > > that > > cxx_constant_init calls is_nondependent_static_init_expression which calls > > instantiation_dependent_expression_p and that is true in A::c. > > Right, because &b is value-dependent. I guess force_paren_expr can't do > that transformation in a template. So do you think that we don't want the patch in Comment 3?