public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late
@ 2004-08-12 19:39 reichelt at gcc dot gnu dot org
2004-08-12 19:40 ` [Bug c++/17011] " reichelt at gcc dot gnu dot org
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-08-12 19:39 UTC (permalink / raw)
To: gcc-bugs
On 3.4 branch and mainline the invalid default parameter is only
diagnosed at instantiation time and not at definition time:
======================================
template<typename> struct A {};
template<typename T> struct B
{
A<T> a;
void foo(A<T>* = &a);
void bar() { foo(); }
};
// template struct B<int>;
======================================
On the 3.3 branch we get the error message already at defintion time:
bug.cc:7: error: invalid use of member `B<T>::a'
--
Summary: [3.4/3.5 regression] invalid default parameter diagnosed
too late
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Keywords: accepts-invalid, diagnostic
Severity: enhancement
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: reichelt at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org,mark at codesourcery dot
com
BugsThisDependsOn: 16929
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/3.5 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
@ 2004-08-12 19:40 ` reichelt at gcc dot gnu dot org
2004-08-12 21:12 ` bangerth at dealii dot org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-08-12 19:40 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |3.4.2 3.5.0
Known to work| |3.3.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/3.5 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
2004-08-12 19:40 ` [Bug c++/17011] " reichelt at gcc dot gnu dot org
@ 2004-08-12 21:12 ` bangerth at dealii dot org
2004-08-12 22:21 ` mark at codesourcery dot com
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: bangerth at dealii dot org @ 2004-08-12 21:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-08-12 21:12 -------
I had to do some research when discussing a bug within IBM's xlC compiler a week ago,
and here simply paste a piece from a mail to them that also seems relevant in the
present context:
-----------------------------------
However, here's the catch: let's assume that we may cause an implicit
instantiation. Then, 14.7.1/1 says: "The implicit instantiation of a class
template specialization causes the instantiation of the declarations, but
not of the definitions or default arguments...".
Furthermore, 14.7.2 says: "Unless a call is to a [...] member function of
an explicitly specialized class template, a default argument for a [...]
member function of a class template is implicitly instantiated when the
function is called in a context that requires the value of the default
argument."
Additionally, 14.7.1/11 indicates to me that default arguments are only
evaluated at the point where they are actually used.
-----------------------------------
This all may or may not be imminent here, but it at least points to the right paragraphs
that state when exactly a default argument shall be evaluated.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/3.5 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
2004-08-12 19:40 ` [Bug c++/17011] " reichelt at gcc dot gnu dot org
2004-08-12 21:12 ` bangerth at dealii dot org
@ 2004-08-12 22:21 ` mark at codesourcery dot com
2004-08-12 22:55 ` giovannibajo at libero dot it
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mark at codesourcery dot com @ 2004-08-12 22:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mark at codesourcery dot com 2004-08-12 22:20 -------
Subject: Re: [3.4/3.5 regression] invalid default parameter
diagnosed too late
bangerth at dealii dot org wrote:
>------- Additional Comments From bangerth at dealii dot org 2004-08-12 21:12 -------
>I had to do some research when discussing a bug within IBM's xlC compiler a week ago,
>and here simply paste a piece from a mail to them that also seems relevant in the
>present context:
>-----------------------------------
>However, here's the catch: let's assume that we may cause an implicit
>instantiation. Then, 14.7.1/1 says: "The implicit instantiation of a class
>template specialization causes the instantiation of the declarations, but
>not of the definitions or default arguments...".
>
>Furthermore, 14.7.2 says: "Unless a call is to a [...] member function of
>an explicitly specialized class template, a default argument for a [...]
>member function of a class template is implicitly instantiated when the
>function is called in a context that requires the value of the default
>argument."
>
>Additionally, 14.7.1/11 indicates to me that default arguments are only
>evaluated at the point where they are actually used.
>-----------------------------------
>
>This all may or may not be imminent here, but it at least points to the right paragraphs
>that state when exactly a default argument shall be evaluated.
>
>
That's a good point. I forgot about that. I'm not sure exactly how it
plays in with the QoI issue in 17011; it might mean that it would be
invalid for the compiler to issue a diagnostic, or it might nt. But,
it's certainly interesting.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/3.5 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-08-12 22:21 ` mark at codesourcery dot com
@ 2004-08-12 22:55 ` giovannibajo at libero dot it
2004-08-12 23:59 ` bangerth at dealii dot org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: giovannibajo at libero dot it @ 2004-08-12 22:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-08-12 22:55 -------
Uhm I'm not sure those paragraphs are pertinent. They say that the default
arguments are *instantiated* when they are actually used.
But the PR is about a default argument having a totally wrong syntax: "&a" is
invalid if a is not a static member, and surely it's type is not A<T>* (in the
best case, it would have to be "A<T>* B<T>::*", that is a pointer-to-member).
I guess this basic kind of syntax and type checking is totally orthogonal to
the instantiation time. I incline to confirm this bug.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-08-12 22:55:33
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/3.5 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
` (3 preceding siblings ...)
2004-08-12 22:55 ` giovannibajo at libero dot it
@ 2004-08-12 23:59 ` bangerth at dealii dot org
2004-10-07 16:23 ` [Bug c++/17011] [3.4/4.0 " pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: bangerth at dealii dot org @ 2004-08-12 23:59 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-08-12 23:59 -------
No, the type of &a is of course the same as the type of &this->a, i.e.
a pointer to an object, not a pointer-to-member. For that you would
have to use &B<T>::a. The invalid part in the code Volker showed is
the implicit reference to this->, which is explicitly not allowed
by the standard.
One of the reasons why you may not want to parse default arguments
at template definition time is that you cannot know whether this code,
for example, is going to be valid or not:
------------------
template <typename T> struct X {
int g (int = T(1));
};
------------------
(Think a template type T for which there is no constructor that takes
an integer.) Now, you will say that here we have a dependent call, whereas
in the original case we do not, but that may actually be hard to
figure out in some cases. I guess that it's cases like these that led
the committee to suggest that default arguments are only evaluated at the
time of use.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/4.0 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-08-12 23:59 ` bangerth at dealii dot org
@ 2004-10-07 16:23 ` pinskia at gcc dot gnu dot org
2004-10-12 12:48 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-07 16:23 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|3.4.2 4.0 |3.4.2 4.0.0 3.3.4
Target Milestone|--- |3.4.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/4.0 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
` (5 preceding siblings ...)
2004-10-07 16:23 ` [Bug c++/17011] [3.4/4.0 " pinskia at gcc dot gnu dot org
@ 2004-10-12 12:48 ` pinskia at gcc dot gnu dot org
2004-11-01 0:45 ` mmitchel at gcc dot gnu dot org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-12 12:48 UTC (permalink / raw)
To: gcc-bugs
--
Bug 17011 depends on bug 16929, which changed state.
Bug 16929 Summary: [3.4/4.0 Regression] ICE on taking address of member in default parameter to member function
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16929
What |Old Value |New Value
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/4.0 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
` (6 preceding siblings ...)
2004-10-12 12:48 ` pinskia at gcc dot gnu dot org
@ 2004-11-01 0:45 ` mmitchel at gcc dot gnu dot org
2004-11-28 6:04 ` lerdsuwa at gcc dot gnu dot org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-11-01 0:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-11-01 00:45 -------
Postponed until GCC 3.4.4.
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4.3 |3.4.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/4.0 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
` (7 preceding siblings ...)
2004-11-01 0:45 ` mmitchel at gcc dot gnu dot org
@ 2004-11-28 6:04 ` lerdsuwa at gcc dot gnu dot org
2004-12-03 10:24 ` lerdsuwa at gcc dot gnu dot org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-11-28 6:04 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-11-28 06:03 -------
Under investigation.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |lerdsuwa at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/4.0 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
` (8 preceding siblings ...)
2004-11-28 6:04 ` lerdsuwa at gcc dot gnu dot org
@ 2004-12-03 10:24 ` lerdsuwa at gcc dot gnu dot org
2004-12-04 6:45 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-12-03 10:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-12-03 10:24 -------
Patch submitted:
http://gcc.gnu.org/ml/gcc-patches/2004-12/msg00255.html
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/4.0 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
` (9 preceding siblings ...)
2004-12-03 10:24 ` lerdsuwa at gcc dot gnu dot org
@ 2004-12-04 6:45 ` cvs-commit at gcc dot gnu dot org
2004-12-04 6:55 ` cvs-commit at gcc dot gnu dot org
2004-12-04 7:06 ` lerdsuwa at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-12-04 6:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-12-04 06:45 -------
Subject: Bug 17011
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: lerdsuwa@gcc.gnu.org 2004-12-04 06:45:14
Modified files:
gcc/cp : ChangeLog pt.c semantics.c
gcc/testsuite : ChangeLog
gcc/testsuite/g++.dg/template: error15.C instantiate3.C
Log message:
PR c++/17011, c++/17971
* pt.c (tsubst_copy) <FIELD_DECL case>: Check and diagnose
invalid field.
(tsubst_copy_and_build) <COMPONENT_REF case>: Check
error_mark_node after member substitution.
* semantics.c (finish_id_expression): Call
finish_non_static_data_member for non-dependent FIELD_DECL.
* g++.dg/template/error15.C: Adjust expected error.
* g++.dg/template/instantiate3.C: Likewise.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4514&r2=1.4515
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.953&r2=1.954
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.450&r2=1.451
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4713&r2=1.4714
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error15.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/instantiate3.C.diff?cvsroot=gcc&r1=1.3&r2=1.4
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/4.0 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
` (10 preceding siblings ...)
2004-12-04 6:45 ` cvs-commit at gcc dot gnu dot org
@ 2004-12-04 6:55 ` cvs-commit at gcc dot gnu dot org
2004-12-04 7:06 ` lerdsuwa at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-12-04 6:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-12-04 06:55 -------
Subject: Bug 17011
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_4-branch
Changes by: lerdsuwa@gcc.gnu.org 2004-12-04 06:55:00
Modified files:
gcc/cp : ChangeLog pt.c semantics.c
gcc/testsuite : ChangeLog
gcc/testsuite/g++.dg/template: error15.C instantiate3.C
Log message:
PR c++/17011, c++/17971
* pt.c (tsubst_copy) <FIELD_DECL case>: Check and diagnose
invalid field.
(tsubst_copy_and_build) <COMPONENT_REF case>: Check
error_mark_node after member substitution.
* semantics.c (finish_id_expression): Call
finish_non_static_data_member for dependent FIELD_DECL.
* g++.dg/template/error15.C: Adjust expected error.
* g++.dg/template/instantiate3.C: Likewise.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.181&r2=1.3892.2.182
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.46&r2=1.816.2.47
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.381.4.15&r2=1.381.4.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.317&r2=1.3389.2.318
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error15.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1.2.1&r2=1.1.2.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/instantiate3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2&r2=1.2.20.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/17011] [3.4/4.0 regression] invalid default parameter diagnosed too late
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
` (11 preceding siblings ...)
2004-12-04 6:55 ` cvs-commit at gcc dot gnu dot org
@ 2004-12-04 7:06 ` lerdsuwa at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-12-04 7:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-12-04 07:06 -------
Fixed in 3.4 branch and mainline.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17011
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2004-12-04 7:06 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-12 19:39 [Bug c++/17011] New: [3.4/3.5 regression] invalid default parameter diagnosed too late reichelt at gcc dot gnu dot org
2004-08-12 19:40 ` [Bug c++/17011] " reichelt at gcc dot gnu dot org
2004-08-12 21:12 ` bangerth at dealii dot org
2004-08-12 22:21 ` mark at codesourcery dot com
2004-08-12 22:55 ` giovannibajo at libero dot it
2004-08-12 23:59 ` bangerth at dealii dot org
2004-10-07 16:23 ` [Bug c++/17011] [3.4/4.0 " pinskia at gcc dot gnu dot org
2004-10-12 12:48 ` pinskia at gcc dot gnu dot org
2004-11-01 0:45 ` mmitchel at gcc dot gnu dot org
2004-11-28 6:04 ` lerdsuwa at gcc dot gnu dot org
2004-12-03 10:24 ` lerdsuwa at gcc dot gnu dot org
2004-12-04 6:45 ` cvs-commit at gcc dot gnu dot org
2004-12-04 6:55 ` cvs-commit at gcc dot gnu dot org
2004-12-04 7:06 ` lerdsuwa at gcc dot gnu dot org
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).