This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix c++/23437


Giovanni Bajo wrote:
Hello,

this simple patch fixes PR c++/23437. It seems that the simple logic
implemented in finish_id_expression for checking for non-constants variables
is actually broken for template arguments. Those constraints are better
checked by convert_nontype_argument. Thus, we allow them at parsing time and
let pt.c handle them.

I don't think the checks are broken; rather it's the case that when we enter template arguments we no longer need to obey the rules for integral constant expressions.


This is a bug in the standard; a literal reading of the standard would imply that:

  template <int *P> struct S {
    static const int I = 3;
  };
  int i;
  int a[S<&i>::I];

is invalid, because "&i" is not allowed in an integral constant expression. I'll ask for a DR, but I think it's obvious that this code should be valid.

So, your patch is OK, but not for the reason that you say, and you should add comments where you set the integral constant expression flag to false to indicate why we need to turn those flags off.

Thanks,

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]