public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11540] New: Redefinition of default arguments allowed for template functions
@ 2003-07-16 8:13 philippe dot haution at mines-paris dot org
2003-07-16 14:02 ` [Bug c++/11540] " bangerth at dealii dot org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: philippe dot haution at mines-paris dot org @ 2003-07-16 8:13 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
Summary: Redefinition of default arguments allowed for template
functions
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: philippe dot haution at mines-paris dot org
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
The following code is deemed legal by gcc, although it breaks the one definition
per translation unit rule :
testcase.cc :
-----------------------
namespace ns
{
template<typename Tv>
int convert_from_v(Tv v, int prec = -1)
{ return 1; }
}
namespace ns
{
template<typename Tv>
int convert_from_v(Tv v, int prec = -2);
}
int main()
{
return ns::convert_from_v<int>(1);
}
$ g++ testcase.cc -o testcase
$ testcase
$ echo $?
255
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
@ 2003-07-16 14:02 ` bangerth at dealii dot org
2003-07-16 14:16 ` nathan at gcc dot gnu dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2003-07-16 14:02 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
------- Additional Comments From bangerth at dealii dot org 2003-07-16 14:02 -------
The code is legal: first, there is only one definition (but two declarations),
so the one-definition rule is inapplicable. Besides a violation of the ODR
does not require a diagonstic.
On the other hand, 8.6.3/4 specifically allows your case, saying that
default arguments defined in different scopes have completely independent
values.
W.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
2003-07-16 14:02 ` [Bug c++/11540] " bangerth at dealii dot org
@ 2003-07-16 14:16 ` nathan at gcc dot gnu dot org
2003-07-16 14:39 ` bangerth at dealii dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-07-16 14:16 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
nathan at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
------- Additional Comments From nathan at gcc dot gnu dot org 2003-07-16 14:16 -------
Wolfgang, they are in the same scope though.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
2003-07-16 14:02 ` [Bug c++/11540] " bangerth at dealii dot org
2003-07-16 14:16 ` nathan at gcc dot gnu dot org
@ 2003-07-16 14:39 ` bangerth at dealii dot org
2003-07-17 8:38 ` philippe dot haution at mines-paris dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2003-07-16 14:39 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2003-07-16 14:39:52
date| |
------- Additional Comments From bangerth at dealii dot org 2003-07-16 14:39 -------
Um, why? The namespace is closed and then opened again. Isn't this two
different scopes?
Alas, you have a point -- sorry for being so quick in closing the PR.
I made a couple of more experiments. We don't get a warning when I don't
close and reopen the namespace. On the other hand, I _do_ get a warning
when the function is not a template, with or without closing the
namespace in between. So this has to do with when default arguments
are parsed for templates. I remember writing a comment about exactly
this in one of our other PRs, but I can't find it :-( The story of
that PR was that default arguments are really only parsed at the
point of _instantiation_ of the template -- but that would be clearly
too late here, unless we parsed the default arguments of _all_ the
declarations we have seen so far for a function, and made sure that
they match.
W.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
` (2 preceding siblings ...)
2003-07-16 14:39 ` bangerth at dealii dot org
@ 2003-07-17 8:38 ` philippe dot haution at mines-paris dot org
2003-07-18 14:19 ` bangerth at dealii dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: philippe dot haution at mines-paris dot org @ 2003-07-17 8:38 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
------- Additional Comments From philippe dot haution at mines-paris dot org 2003-07-17 08:38 -------
8.6.3/4 asserts that a default argument shall not be redefined by a later
declaration, not even to the same value; so I am afraid checking that all
declarations of default arguments have the same value wouldn't be enough here,
the compiler should also check that there is only one definition of default
arguments per translation unit.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
` (3 preceding siblings ...)
2003-07-17 8:38 ` philippe dot haution at mines-paris dot org
@ 2003-07-18 14:19 ` bangerth at dealii dot org
2003-08-06 14:35 ` bangerth at dealii dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2003-07-18 14:19 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4 |---
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
` (4 preceding siblings ...)
2003-07-18 14:19 ` bangerth at dealii dot org
@ 2003-08-06 14:35 ` bangerth at dealii dot org
2003-08-06 14:36 ` bangerth at dealii dot org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2003-08-06 14:35 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2003-08-06 14:35 -------
*** Bug 11827 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
` (5 preceding siblings ...)
2003-08-06 14:35 ` bangerth at dealii dot org
@ 2003-08-06 14:36 ` bangerth at dealii dot org
2003-08-06 14:40 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2003-08-06 14:36 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
------- Additional Comments From bangerth at dealii dot org 2003-08-06 14:36 -------
PR 11827 has some more information, as well as a small patch by Jakub.
W.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
` (6 preceding siblings ...)
2003-08-06 14:36 ` bangerth at dealii dot org
@ 2003-08-06 14:40 ` jakub at gcc dot gnu dot org
2003-08-23 2:05 ` dhazeghi at yahoo dot com
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2003-08-06 14:40 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |3.3.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
` (7 preceding siblings ...)
2003-08-06 14:40 ` jakub at gcc dot gnu dot org
@ 2003-08-23 2:05 ` dhazeghi at yahoo dot com
2004-07-13 19:42 ` jens dot maurer at gmx dot net
2004-07-13 20:13 ` giovannibajo at libero dot it
10 siblings, 0 replies; 12+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-23 2:05 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
dhazeghi at yahoo dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.3.2 |---
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
` (8 preceding siblings ...)
2003-08-23 2:05 ` dhazeghi at yahoo dot com
@ 2004-07-13 19:42 ` jens dot maurer at gmx dot net
2004-07-13 20:13 ` giovannibajo at libero dot it
10 siblings, 0 replies; 12+ messages in thread
From: jens dot maurer at gmx dot net @ 2004-07-13 19:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jens dot maurer at gmx dot net 2004-07-13 19:42 -------
This bug looks like a duplicate of bug 15339 to me.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/11540] Redefinition of default arguments allowed for template functions
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
` (9 preceding siblings ...)
2004-07-13 19:42 ` jens dot maurer at gmx dot net
@ 2004-07-13 20:13 ` giovannibajo at libero dot it
10 siblings, 0 replies; 12+ messages in thread
From: giovannibajo at libero dot it @ 2004-07-13 20:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-07-13 20:13 -------
Yes, thanks for the tip.
*** This bug has been marked as a duplicate of 15339 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11540
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2004-07-13 20:13 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-16 8:13 [Bug c++/11540] New: Redefinition of default arguments allowed for template functions philippe dot haution at mines-paris dot org
2003-07-16 14:02 ` [Bug c++/11540] " bangerth at dealii dot org
2003-07-16 14:16 ` nathan at gcc dot gnu dot org
2003-07-16 14:39 ` bangerth at dealii dot org
2003-07-17 8:38 ` philippe dot haution at mines-paris dot org
2003-07-18 14:19 ` bangerth at dealii dot org
2003-08-06 14:35 ` bangerth at dealii dot org
2003-08-06 14:36 ` bangerth at dealii dot org
2003-08-06 14:40 ` jakub at gcc dot gnu dot org
2003-08-23 2:05 ` dhazeghi at yahoo dot com
2004-07-13 19:42 ` jens dot maurer at gmx dot net
2004-07-13 20:13 ` 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).