[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
jason at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 27 17:08:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
(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.
More information about the Gcc-bugs
mailing list