From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8271 invoked by alias); 18 Mar 2004 15:32:03 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 8213 invoked by alias); 18 Mar 2004 15:32:01 -0000 Date: Thu, 18 Mar 2004 15:32:00 -0000 Message-ID: <20040318153201.8212.qmail@sources.redhat.com> From: "giovannibajo at libero dot it" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040312062911.14545.schmid@snake.iap.physik.tu-darmstadt.de> References: <20040312062911.14545.schmid@snake.iap.physik.tu-darmstadt.de> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/14545] [3.4/3.5 Regression] Cannot compile pooma-gcc (regression) X-Bugzilla-Reason: CC X-SW-Source: 2004-03/txt/msg02207.txt.bz2 List-Id: ------- Additional Comments From giovannibajo at libero dot it 2004-03-18 15:31 ------- Subject: Re: [3.4/3.5 Regression] Cannot compile pooma-gcc (regression) bangerth at dealii dot org wrote: > This whole business with non-dependent initializers has run somehow > out of control given how late we are in the release cycle. We must > have had at least a dozen different reports about this problem. Has anyone > considered reverting the patch that introduced this instability? We > seem to be stomping out fires that keep popping up everywhere... The patch just helps finding latent problems, really. It's not that the patch was not complete or instable, it just somehow helps uncovering problems with our detection of constant expressions. Plus, we're making big progress, because now it's always possible to use const locals as template arguments while before it was failing very often. Anyway, this is the updated patch, and I'm running the regression test right now. OK for mainline and 3.4 if it passes? Giovanni Bajo 2004-03-16 Giovanni Bajo PR c++/14545 * parser.c (cp_parser_functional_cast): A cast to anything but integral or enumaration type is not an integral constant expression. * pt.c (value_dependent_expression_p): Handle cast expressions without operands (such as "int()"). 2004-03-16 Giovanni Bajo PR c++/14545 * g++.dg/parse/template15.C: New test. Index: parser.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v retrieving revision 1.183 diff -c -3 -p -r1.183 parser.c *** parser.c 16 Mar 2004 22:17:59 -0000 1.183 --- parser.c 18 Mar 2004 01:04:57 -0000 *************** static tree *** 14477,14488 **** cp_parser_functional_cast (cp_parser* parser, tree type) { tree expression_list; expression_list = cp_parser_parenthesized_expression_list (parser, false, /*non_constant_p=*/NULL); ! return build_functional_cast (type, expression_list); } /* Save the tokens that make up the body of a member function defined --- 14477,14499 ---- cp_parser_functional_cast (cp_parser* parser, tree type) { tree expression_list; + tree cast; expression_list = cp_parser_parenthesized_expression_list (parser, false, /*non_constant_p=*/NULL); ! cast = build_functional_cast (type, expression_list); ! /* [expr.const]/1: In an integral constant expression "only type ! conversions to integral or enumeration type can be used". */ ! if (cast != error_mark_node && !type_dependent_expression_p (type) ! && !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (type))) ! { ! if (cp_parser_non_integral_constant_expression ! (parser, "a call to a constructor")) ! return error_mark_node; ! } ! return cast; } /* Save the tokens that make up the body of a member function defined Index: pt.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v retrieving revision 1.840 diff -c -3 -p -r1.840 pt.c *** pt.c 16 Mar 2004 22:18:05 -0000 1.840 --- pt.c 18 Mar 2004 14:43:40 -0000 *************** value_dependent_expression_p (tree expre *** 11776,11785 **** || TREE_CODE (expression) == REINTERPRET_CAST_EXPR || TREE_CODE (expression) == CAST_EXPR) { ! if (dependent_type_p (TREE_TYPE (expression))) return true; /* A functional cast has a list of operands. */ expression = TREE_OPERAND (expression, 0); if (TREE_CODE (expression) == TREE_LIST) { do --- 11776,11796 ---- || TREE_CODE (expression) == REINTERPRET_CAST_EXPR || TREE_CODE (expression) == CAST_EXPR) { ! tree type = TREE_TYPE (expression); ! if (dependent_type_p (type)) return true; /* A functional cast has a list of operands. */ expression = TREE_OPERAND (expression, 0); + if (!expression) + { + /* If there are no operands, it must be an expression such + as "int()". This should not happen for aggregate types + because it would form non-constant expressions. */ + my_friendly_assert (INTEGRAL_OR_ENUMERATION_TYPE_P (type), + 20040318); + + return false; + } if (TREE_CODE (expression) == TREE_LIST) { do // { dg-do compile } // Contributed by: Peter Schmid // // PR c++/14545: constructor calls are not integer constant expressions struct A1 { A1(); }; struct A2 { }; template struct B { void foo() { A1(); A1 a1 = A1(); A2(); A2 a2 = A2(); int(); int a3 = int(); float(); float a4 = float(); } }; template struct B; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14545