This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix c++/23437
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Giovanni Bajo <rasky at develer dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 22 Aug 2005 00:42:45 +0100
- Subject: Re: [C++ PATCH] Fix c++/23437
- References: <053001c5a4e8$a094a030$bf03030a@trilan>
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