* [Bug c++/35146] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
@ 2008-02-09 1:45 ` pinskia at gcc dot gnu dot org
2008-02-10 1:13 ` [Bug c++/35146] [4.1/4.2 regression] " bangerth at dealii dot org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-09 1:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2008-02-09 01:45 -------
This works fine on the trunk.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.1/4.2 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
2008-02-09 1:45 ` [Bug c++/35146] " pinskia at gcc dot gnu dot org
@ 2008-02-10 1:13 ` bangerth at dealii dot org
2008-02-10 23:07 ` rguenth at gcc dot gnu dot org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2008-02-10 1:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from bangerth at dealii dot org 2008-02-10 01:13 -------
Confirmed. This was introduced in 3.4.x, and worked before. As Andrew
already noted, this has been fixed in mainline.
The problem can be more succinctly shown by the following testcase:
--------------------
template <typename T> struct S {};
template <typename R> struct ref;
template <> struct ref<double> { typedef double result; };
template <typename T> void foo(typename ref<T>::result, S<T>*);
template <> void foo(S<double>, S<double>*);
template <> void foo(double alpha, S<double>* x)
{
alpha; x;
}
-----------------------
g/x> c++-4.2.1 -S x.cc
x.cc: In function 'void foo(typename ref<R>::result, S<T>*) [with T = double]':
x.cc:10: error: 'alpha' was not declared in this scope
x.cc:10: error: 'x' was not declared in this scope
What is happening is that we are looking up the parameters from the wrong
declaration. The function in question on line 10 of course has them
declared and named, but we are looking at the specialization in line 7:
if the parameters are named there, then the code compiles. However, as
shown in the original testcase, the parameters then have the wrong
type.
It shouldn't be too hard to construct a case where this produces wrong
code.
Can someone determine whether this is still wrong with the released
4.2.3? I consider this a particularly heinous bug since it's almost
impossible to see in a real code where the error is coming from (if
we get one) or why the produced code is wrong.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Known to fail| |4.2.1 4.1.2 4.0.4 3.4.6
Known to work|4.3.0 |4.3.0 3.3.6
Last reconfirmed|0000-00-00 00:00:00 |2008-02-10 01:13:11
date| |
Summary|weird error in template |[4.1/4.2 regression] weird
|function specialization |error in template function
| |specialization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.1/4.2 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
2008-02-09 1:45 ` [Bug c++/35146] " pinskia at gcc dot gnu dot org
2008-02-10 1:13 ` [Bug c++/35146] [4.1/4.2 regression] " bangerth at dealii dot org
@ 2008-02-10 23:07 ` rguenth at gcc dot gnu dot org
2008-02-11 3:38 ` bangerth at dealii dot org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-10 23:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2008-02-10 23:06 -------
While the original testcase works for me on trunk, the testcase in comment #2
does
not. Or am I missing sth?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.1/4.2 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (2 preceding siblings ...)
2008-02-10 23:07 ` rguenth at gcc dot gnu dot org
@ 2008-02-11 3:38 ` bangerth at dealii dot org
2008-02-15 17:12 ` grey_earl at web dot de
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2008-02-11 3:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from bangerth at dealii dot org 2008-02-11 03:38 -------
(In reply to comment #3)
> While the original testcase works for me on trunk, the testcase in comment #2
> does
> not. Or am I missing sth?
I see the same behavior with yesterday's svn version. The testcase in
comment #2 is definitely valid, so we still have a regression.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.1/4.2 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (3 preceding siblings ...)
2008-02-11 3:38 ` bangerth at dealii dot org
@ 2008-02-15 17:12 ` grey_earl at web dot de
2008-03-27 22:24 ` rguenth at gcc dot gnu dot org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: grey_earl at web dot de @ 2008-02-15 17:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from grey_earl at web dot de 2008-02-15 17:12 -------
Both testcases fail with 4.2.3 release version, with exactly the same errors.
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--disable-libmudflap --enable-targets=all --enable-checking=release
--build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 (Debian 4.2.3-1)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.1/4.2 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (4 preceding siblings ...)
2008-02-15 17:12 ` grey_earl at web dot de
@ 2008-03-27 22:24 ` rguenth at gcc dot gnu dot org
2008-07-04 22:34 ` [Bug c++/35146] [4.2 " jsm28 at gcc dot gnu dot org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-27 22:24 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.2 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (5 preceding siblings ...)
2008-03-27 22:24 ` rguenth at gcc dot gnu dot org
@ 2008-07-04 22:34 ` jsm28 at gcc dot gnu dot org
2009-03-31 15:10 ` [Bug c++/35146] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 22:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jsm28 at gcc dot gnu dot org 2008-07-04 22:33 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2 regression] weird |[4.2 regression] weird error
|error in template function |in template function
|specialization |specialization
Target Milestone|4.1.3 |4.2.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.3/4.4/4.5 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (6 preceding siblings ...)
2008-07-04 22:34 ` [Bug c++/35146] [4.2 " jsm28 at gcc dot gnu dot org
@ 2009-03-31 15:10 ` jsm28 at gcc dot gnu dot org
2009-04-06 20:15 ` jason at gcc dot gnu dot org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-31 15:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jsm28 at gcc dot gnu dot org 2009-03-31 15:10 -------
Closing 4.2 branch, original test fixed in 4.3. However, there's a note here
about the test in comment#2 being valid and failing on trunk as of a year
ago, and that test does still fail, so marking as a 4.3/4.4/4.5 regression
instead of closing.
(I have not tried to check if the test in comment#2 is indeed valid, or if
it is indeed a regression from some previous version.)
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|4.2.1 4.1.2 4.0.4 3.4.6 |4.2.1 4.1.2 4.0.4 3.4.6
| |4.2.5
Known to work|4.3.0 3.3.6 |3.3.6
Last reconfirmed|2008-02-10 01:13:11 |2009-03-31 15:10:20
date| |
Summary|[4.2 regression] weird error|[4.3/4.4/4.5 regression]
|in template function |weird error in template
|specialization |function specialization
Target Milestone|4.2.5 |4.3.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.3/4.4/4.5 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (7 preceding siblings ...)
2009-03-31 15:10 ` [Bug c++/35146] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
@ 2009-04-06 20:15 ` jason at gcc dot gnu dot org
2009-04-06 20:29 ` jason at gcc dot gnu dot org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-04-06 20:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jason at gcc dot gnu dot org 2009-04-06 20:14 -------
The testcase in comment #2 is ill-formed;
template <> void foo(S<double>, S<double>*);
is not a specialization of any function template in scope. But we're giving
very much the wrong error for that. Testing a patch now.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jason at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2009-03-31 15:10:20 |2009-04-06 20:14:50
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.3/4.4/4.5 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (8 preceding siblings ...)
2009-04-06 20:15 ` jason at gcc dot gnu dot org
@ 2009-04-06 20:29 ` jason at gcc dot gnu dot org
2009-04-06 20:55 ` jason at gcc dot gnu dot org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-04-06 20:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jason at gcc dot gnu dot org 2009-04-06 20:29 -------
...and GCC miscompiles the original testcase due to the same bug.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.3/4.4/4.5 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (9 preceding siblings ...)
2009-04-06 20:29 ` jason at gcc dot gnu dot org
@ 2009-04-06 20:55 ` jason at gcc dot gnu dot org
2009-04-06 21:35 ` jason at gcc dot gnu dot org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-04-06 20:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jason at gcc dot gnu dot org 2009-04-06 20:55 -------
Subject: Bug 35146
Author: jason
Date: Mon Apr 6 20:55:04 2009
New Revision: 145625
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145625
Log:
PR c++/35146
* pt.c (fn_type_unification): For DEDUCE_EXACT check that
the deduced template arguments give us the parameter types
we're looking for.
Added:
trunk/gcc/testsuite/g++.dg/template/fnspec1.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.3/4.4/4.5 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (10 preceding siblings ...)
2009-04-06 20:55 ` jason at gcc dot gnu dot org
@ 2009-04-06 21:35 ` jason at gcc dot gnu dot org
2009-04-07 3:51 ` jason at gcc dot gnu dot org
2009-04-07 4:46 ` jason at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-04-06 21:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from jason at gcc dot gnu dot org 2009-04-06 21:35 -------
Subject: Bug 35146
Author: jason
Date: Mon Apr 6 21:35:29 2009
New Revision: 145634
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145634
Log:
PR c++/35146
* pt.c (fn_type_unification): For DEDUCE_EXACT check that
the deduced template arguments give us the parameter types
we're looking for.
Added:
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/fnspec1.C
Modified:
branches/gcc-4_4-branch/gcc/cp/ChangeLog
branches/gcc-4_4-branch/gcc/cp/pt.c
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.3/4.4/4.5 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (11 preceding siblings ...)
2009-04-06 21:35 ` jason at gcc dot gnu dot org
@ 2009-04-07 3:51 ` jason at gcc dot gnu dot org
2009-04-07 4:46 ` jason at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-04-07 3:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from jason at gcc dot gnu dot org 2009-04-07 03:51 -------
Subject: Bug 35146
Author: jason
Date: Tue Apr 7 03:50:49 2009
New Revision: 145647
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145647
Log:
PR c++/35146
* pt.c (fn_type_unification): For DEDUCE_EXACT check that
the deduced template arguments give us the parameter types
we're looking for.
Added:
branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/fnspec1.C
Modified:
branches/gcc-4_3-branch/gcc/cp/ChangeLog
branches/gcc-4_3-branch/gcc/cp/pt.c
branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/35146] [4.3/4.4/4.5 regression] weird error in template function specialization
2008-02-09 1:41 [Bug c++/35146] New: weird error in template function specialization grey_earl at web dot de
` (12 preceding siblings ...)
2009-04-07 3:51 ` jason at gcc dot gnu dot org
@ 2009-04-07 4:46 ` jason at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-04-07 4:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from jason at gcc dot gnu dot org 2009-04-07 04:46 -------
Fixed.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146
^ permalink raw reply [flat|nested] 15+ messages in thread