public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18354] New: expression "+1" not considered constant (as template parameter).
@ 2004-11-07 11:50 fsm at robots dot ox dot ac dot uk
2004-11-07 15:46 ` [Bug c++/18354] [4.0 Regression] " pinskia at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: fsm at robots dot ox dot ac dot uk @ 2004-11-07 11:50 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1842 bytes --]
Have class templated over "int". Compiler does not accept "+1" as template
parameter on the grounds that it is not a constant expression. Compiler accepts
both "-1" and "1".
This bug appears in: gcc version 4.0.0 20041107 (experimental)
gcc version 4.0.0 20041106 (experimental)
It did not appear in: gcc version 4.0.0 20040927 (experimental)
The following code reproduces the problem.
---------------------8<-------------------
template <int N>
struct X { };
void f()
{
X< 1> a;
X<-1> b;
X<+1> c; // <-- error here.
}
---------------------8<-------------------
$ g++ -c f.cxx
f.cxx: In function void f():
f.cxx:8: error: 1 is not a valid template argument for type int because it
is a non-constant expression
f.cxx:8: error: invalid type in declaration before ; token
$ uname -a
Linux theseus 2.4.20-8smp #1 SMP Thu Mar 13 17:45:54 EST 2003 i686 i686 i386
GNU/Linux
$ g++ -v
Reading specs from /lvm/fred/gcc/cvs/install/lib/gcc/i686-pc-linux-gnu/4.0.0/specs
Configured with: ../gcc/configure --prefix=/lvm/fred/gcc/cvs/install
--enable-static --enable-shared --enable-languages=c,c++,f95
--with-mpfr=/lvm/fred/pkg/gmp/install
Thread model: posix
gcc version 4.0.0 20041107 (experimental)
--
Summary: expression "+1" not considered constant (as template
parameter).
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fsm at robots dot ox dot ac dot uk
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18354
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/18354] [4.0 Regression] expression "+1" not considered constant (as template parameter).
2004-11-07 11:50 [Bug c++/18354] New: expression "+1" not considered constant (as template parameter) fsm at robots dot ox dot ac dot uk
@ 2004-11-07 15:46 ` pinskia at gcc dot gnu dot org
2004-11-07 20:54 ` giovannibajo at libero dot it
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-07 15:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-11-07 15:46 -------
Confirmed a regression.
: Search converges between 2004-11-04-014001-trunk (#614) and 2004-11-04-161001-trunk
(#615).
Caused by:
2004-11-04 Giovanni Bajo <giovannibajo@gcc.gnu.org>
DR 49, 100
* cp-tree.h (TYPE_REF_OBJ_P): New macro.
(TYPE_PTR_P, TYPE_PTROB_P, TYPE_PTROBV_P, TYPE_PTRFN_P,
TYPE_REFFN_P): Document.
(fold_decl_constant_value): New prototype.
* pt.c (convert_nontype_argument_function): Rewrite and extract
parts into...
(fold_decl_constant_value, convert_nontype_argument_function): New.
(lookup_template_class): Add comment about useless double call.
* mangle.c (write_expression): Strip conversions before lowering
pointer to members.
* cvt.c (ocp_convert): Check LOOKUP_COMPLAIN for a pedwarn. Disallow
enum to enum conversion.
The Comeau online C++ tester accepts the code also.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |giovannibajo at gcc dot gnu
| |dot org, pinskia at gcc dot
| |gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |rejects-valid
Known to fail| |4.0.0
Known to work| |3.4.0
Last reconfirmed|0000-00-00 00:00:00 |2004-11-07 15:46:06
date| |
Summary|expression "+1" not |[4.0 Regression] expression
|considered constant (as |"+1" not considered constant
|template parameter). |(as template parameter).
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18354
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/18354] [4.0 Regression] expression "+1" not considered constant (as template parameter).
2004-11-07 11:50 [Bug c++/18354] New: expression "+1" not considered constant (as template parameter) fsm at robots dot ox dot ac dot uk
2004-11-07 15:46 ` [Bug c++/18354] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2004-11-07 20:54 ` giovannibajo at libero dot it
2004-11-14 1:57 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: giovannibajo at libero dot it @ 2004-11-07 20:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-11-07 20:54 -------
I was waiting for this, in a way
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |giovannibajo at libero dot
|dot org |it
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18354
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/18354] [4.0 Regression] expression "+1" not considered constant (as template parameter).
2004-11-07 11:50 [Bug c++/18354] New: expression "+1" not considered constant (as template parameter) fsm at robots dot ox dot ac dot uk
2004-11-07 15:46 ` [Bug c++/18354] [4.0 Regression] " pinskia at gcc dot gnu dot org
2004-11-07 20:54 ` giovannibajo at libero dot it
@ 2004-11-14 1:57 ` pinskia at gcc dot gnu dot org
2004-11-15 2:01 ` giovannibajo at libero dot it
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-14 1:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-11-14 01:56 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-11/msg01133.html>.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18354
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/18354] [4.0 Regression] expression "+1" not considered constant (as template parameter).
2004-11-07 11:50 [Bug c++/18354] New: expression "+1" not considered constant (as template parameter) fsm at robots dot ox dot ac dot uk
` (2 preceding siblings ...)
2004-11-14 1:57 ` pinskia at gcc dot gnu dot org
@ 2004-11-15 2:01 ` giovannibajo at libero dot it
2004-11-22 12:16 ` cvs-commit at gcc dot gnu dot org
2004-11-22 12:17 ` giovannibajo at libero dot it
5 siblings, 0 replies; 7+ messages in thread
From: giovannibajo at libero dot it @ 2004-11-15 2:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-11-15 02:01 -------
Updated patch:
http://gcc.gnu.org/ml/gcc-patches/2004-11/msg01191.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18354
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/18354] [4.0 Regression] expression "+1" not considered constant (as template parameter).
2004-11-07 11:50 [Bug c++/18354] New: expression "+1" not considered constant (as template parameter) fsm at robots dot ox dot ac dot uk
` (3 preceding siblings ...)
2004-11-15 2:01 ` giovannibajo at libero dot it
@ 2004-11-22 12:16 ` cvs-commit at gcc dot gnu dot org
2004-11-22 12:17 ` giovannibajo at libero dot it
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-11-22 12:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-11-22 12:16 -------
Subject: Bug 18354
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: giovannibajo@gcc.gnu.org 2004-11-22 12:15:54
Modified files:
gcc/cp : ChangeLog typeck.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/template: nontype11.C
Log message:
PR c++/18354
* typeck.c (build_unary_op) <CONVERT_EXPR, NEGATE_EXPR>: Unify code.
Make sure the result is always a rvalue.
PR c++/18354
* g++.dg/template/nontype11.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4486&r2=1.4487
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.596&r2=1.597
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4626&r2=1.4627
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nontype11.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18354
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/18354] [4.0 Regression] expression "+1" not considered constant (as template parameter).
2004-11-07 11:50 [Bug c++/18354] New: expression "+1" not considered constant (as template parameter) fsm at robots dot ox dot ac dot uk
` (4 preceding siblings ...)
2004-11-22 12:16 ` cvs-commit at gcc dot gnu dot org
@ 2004-11-22 12:17 ` giovannibajo at libero dot it
5 siblings, 0 replies; 7+ messages in thread
From: giovannibajo at libero dot it @ 2004-11-22 12:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-11-22 12:17 -------
Committed after Nathan's approval. This bug is now fixed for GCC 4.0, thank you
for your report!
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18354
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-11-22 12:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-07 11:50 [Bug c++/18354] New: expression "+1" not considered constant (as template parameter) fsm at robots dot ox dot ac dot uk
2004-11-07 15:46 ` [Bug c++/18354] [4.0 Regression] " pinskia at gcc dot gnu dot org
2004-11-07 20:54 ` giovannibajo at libero dot it
2004-11-14 1:57 ` pinskia at gcc dot gnu dot org
2004-11-15 2:01 ` giovannibajo at libero dot it
2004-11-22 12:16 ` cvs-commit at gcc dot gnu dot org
2004-11-22 12:17 ` giovannibajo at libero dot it
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).