* [Bug c++/15339] function call error
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
@ 2004-05-07 15:30 ` bangerth at dealii dot org
2004-05-07 16:36 ` llewelly
2004-05-07 15:37 ` bangerth at dealii dot org
` (9 subsequent siblings)
10 siblings, 1 reply; 16+ messages in thread
From: bangerth at dealii dot org @ 2004-05-07 15:30 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-05-07 15:30 -------
Confirmed, here is a smaller testcase:
-----------
template<typename> void fun(int);
template<typename> void fun(int = 0) {}
int main()
{ fun(); }
-----------
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
x.cc: In function `int main()':
x.cc:10: error: no matching function for call to `fun()'
However, we get this from icc:
g/x> icc -Xc -ansi x.cc
x.cc(2): warning #845: specifying a default argument when redeclaring an
unreferenced function template is nonstandard
template<typename> void fun(int = 0) {}
^
x.cc(5): error: no instance of function template "fun" matches the argument
list
{ fun(); }
^
compilation aborted for x.cc (code 2)
So it seems that this is wrong code. Someone will have to look up the exact
text in the standard though. I find it odd that this only applies to
templates, not to non-template functions.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Bug c++/15339] function call error
2004-05-07 15:30 ` [Bug c++/15339] " bangerth at dealii dot org
@ 2004-05-07 16:36 ` llewelly
0 siblings, 0 replies; 16+ messages in thread
From: llewelly @ 2004-05-07 16:36 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
> ------- Additional Comments From bangerth at dealii dot org 2004-05-07 15:30 -------
> Confirmed, here is a smaller testcase:
> -----------
> template<typename> void fun(int);
> template<typename> void fun(int = 0) {}
>
> int main()
> { fun(); }
> -----------
>
> g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
> x.cc: In function `int main()':
> x.cc:10: error: no matching function for call to `fun()'
>
> However, we get this from icc:
> g/x> icc -Xc -ansi x.cc
> x.cc(2): warning #845: specifying a default argument when redeclaring an
> unreferenced function template is nonstandard
> template<typename> void fun(int = 0) {}
> ^
>
> x.cc(5): error: no instance of function template "fun" matches the argument
> list
> { fun(); }
> ^
>
> compilation aborted for x.cc (code 2)
>
>
> So it seems that this is wrong code. Someone will have to look up the exact
> text in the standard though. I find it odd that this only applies to
> templates, not to non-template functions.
It's in 8.3.6/4 . But see issue 226:
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html#226
Basicly, it's a leftover from when there was no way to explicitly
specifiy template arguments for function templates.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/15339] function call error
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
2004-05-07 15:30 ` [Bug c++/15339] " bangerth at dealii dot org
@ 2004-05-07 15:37 ` bangerth at dealii dot org
2004-05-07 16:24 ` Gabriel Dos Reis
2004-05-07 16:24 ` gdr at integrable-solutions dot net
` (8 subsequent siblings)
10 siblings, 1 reply; 16+ messages in thread
From: bangerth at dealii dot org @ 2004-05-07 15:37 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-05-07 15:37 -------
Actually, that was easy. 8.3.6/4 specificly says
For non-template functions, default arguments can be added in later
declarations.
So the code is invalid.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Bug c++/15339] function call error
2004-05-07 15:37 ` bangerth at dealii dot org
@ 2004-05-07 16:24 ` Gabriel Dos Reis
0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2004-05-07 16:24 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| Actually, that was easy. 8.3.6/4 specificly says
| For non-template functions, default arguments can be added in later
| declarations.
|
| So the code is invalid.
Yes, you're right. But we should be diagnosing the declaration
in the first place -- which we fail. So there is an issue here, but
not that one the submitter thought about.
-- Gaby
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/15339] function call error
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
2004-05-07 15:30 ` [Bug c++/15339] " bangerth at dealii dot org
2004-05-07 15:37 ` bangerth at dealii dot org
@ 2004-05-07 16:24 ` gdr at integrable-solutions dot net
2004-05-07 16:36 ` llewelly at xmission dot com
` (7 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-05-07 16:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2004-05-07 16:24 -------
Subject: Re: function call error
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| Actually, that was easy. 8.3.6/4 specificly says
| For non-template functions, default arguments can be added in later
| declarations.
|
| So the code is invalid.
Yes, you're right. But we should be diagnosing the declaration
in the first place -- which we fail. So there is an issue here, but
not that one the submitter thought about.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/15339] function call error
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
` (2 preceding siblings ...)
2004-05-07 16:24 ` gdr at integrable-solutions dot net
@ 2004-05-07 16:36 ` llewelly at xmission dot com
2004-05-07 16:54 ` bangerth at dealii dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: llewelly at xmission dot com @ 2004-05-07 16:36 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From llewelly at xmission dot com 2004-05-07 16:36 -------
Subject: Re: function call error
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
> ------- Additional Comments From bangerth at dealii dot org 2004-05-07 15:30 -------
> Confirmed, here is a smaller testcase:
> -----------
> template<typename> void fun(int);
> template<typename> void fun(int = 0) {}
>
> int main()
> { fun(); }
> -----------
>
> g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
> x.cc: In function `int main()':
> x.cc:10: error: no matching function for call to `fun()'
>
> However, we get this from icc:
> g/x> icc -Xc -ansi x.cc
> x.cc(2): warning #845: specifying a default argument when redeclaring an
> unreferenced function template is nonstandard
> template<typename> void fun(int = 0) {}
> ^
>
> x.cc(5): error: no instance of function template "fun" matches the argument
> list
> { fun(); }
> ^
>
> compilation aborted for x.cc (code 2)
>
>
> So it seems that this is wrong code. Someone will have to look up the exact
> text in the standard though. I find it odd that this only applies to
> templates, not to non-template functions.
It's in 8.3.6/4 . But see issue 226:
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html#226
Basicly, it's a leftover from when there was no way to explicitly
specifiy template arguments for function templates.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/15339] function call error
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
` (3 preceding siblings ...)
2004-05-07 16:36 ` llewelly at xmission dot com
@ 2004-05-07 16:54 ` bangerth at dealii dot org
2004-05-08 16:29 ` giovannibajo at libero dot it
` (5 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: bangerth at dealii dot org @ 2004-05-07 16:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-05-07 16:54 -------
I fail to see the relevance of the DR to the present case. It doesn't
say anything about default arguments for repeated declarations, does
it?
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/15339] function call error
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
` (4 preceding siblings ...)
2004-05-07 16:54 ` bangerth at dealii dot org
@ 2004-05-08 16:29 ` giovannibajo at libero dot it
2004-05-08 16:32 ` [Bug c++/15339] [DR217] Adding default arguments to function templates in redeclartions should be forbidden giovannibajo at libero dot it
` (4 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: giovannibajo at libero dot it @ 2004-05-08 16:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-05-08 16:29 -------
Reopened before there is an issue
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/15339] [DR217] Adding default arguments to function templates in redeclartions should be forbidden
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
` (5 preceding siblings ...)
2004-05-08 16:29 ` giovannibajo at libero dot it
@ 2004-05-08 16:32 ` giovannibajo at libero dot it
2004-05-09 14:19 ` MichaelLi8195 at hotmail dot com
` (3 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: giovannibajo at libero dot it @ 2004-05-08 16:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-05-08 16:32 -------
This should be diagnosed:
------------------------------------
template<typename> void fun(int);
template<typename> void fun(int = 0) {}
------------------------------------
but it's not. I don't think it's a regression, but can anybody check?
Also, DR217 (TC1 status) says that this is also for regular member function of
class templates. In other words, the following is invalid as well:
------------------------------------
template <class T>
struct S
{
void foo (int);
};
template <class T>
void S<T>::foo (int = 0) { }
------------------------------------
(note that this testcase is already in our testsuite: g++.dg/tc1/dr217.C)
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Known to fail| |3.4.0 3.5.0
Summary|function call error |[DR217] Adding default
| |arguments to function
| |templates in redeclartions
| |should be forbidden
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/15339] [DR217] Adding default arguments to function templates in redeclartions should be forbidden
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
` (6 preceding siblings ...)
2004-05-08 16:32 ` [Bug c++/15339] [DR217] Adding default arguments to function templates in redeclartions should be forbidden giovannibajo at libero dot it
@ 2004-05-09 14:19 ` MichaelLi8195 at hotmail dot com
2004-05-09 15:18 ` bangerth at dealii dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: MichaelLi8195 at hotmail dot com @ 2004-05-09 14:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From MichaelLi8195 at hotmail dot com 2004-05-09 14:17 -------
Subject: RE: [DR217] Adding default arguments to function templates in
redeclartions should be forbidden
I could not find "g++.dg/tc1/dr217.C" in the testsuite of the recently
released package gcc-3.4.0.tar.bz2. Where could I get it? Thanks.
>From: "giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org>
>Reply-To: gcc-bugzilla@gcc.gnu.org
>To: MichaelLi8195@hotmail.com
>Subject: [Bug c++/15339] [DR217] Adding default arguments to function
templates in redeclartions should be forbidden
>Date: 8 May 2004 16:32:58 -0000
>
>------- Additional Comments From giovannibajo at libero dot it 2004-05-08
16:32 -------
>This should be diagnosed:
>
>------------------------------------
>template<typename> void fun(int);
>template<typename> void fun(int = 0) {}
>------------------------------------
>
>but it's not. I don't think it's a regression, but can anybody check?
>
>Also, DR217 (TC1 status) says that this is also for regular member
function of
>class templates. In other words, the following is invalid as well:
>
>------------------------------------
> template <class T>
> struct S
> {
> void foo (int);
> };
>
> template <class T>
> void S<T>::foo (int = 0) { }
>------------------------------------
>(note that this testcase is already in our testsuite: g++.dg/tc1/dr217.C)
>
>
>--
> What |Removed |Added
>----------------------------------------------------------------------------
> Keywords| |accepts-invalid
> Known to fail| |3.4.0 3.5.0
> Summary|function call error |[DR217] Adding default
> | |arguments to function
> | |templates in
redeclartions
> | |should be forbidden
>
>
>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
>
>------- You are receiving this mail because: -------
>You reported the bug, or are watching the reporter.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/15339] [DR217] Adding default arguments to function templates in redeclartions should be forbidden
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
` (7 preceding siblings ...)
2004-05-09 14:19 ` MichaelLi8195 at hotmail dot com
@ 2004-05-09 15:18 ` bangerth at dealii dot org
2004-07-13 20:13 ` giovannibajo at libero dot it
2004-07-13 20:14 ` giovannibajo at libero dot it
10 siblings, 0 replies; 16+ messages in thread
From: bangerth at dealii dot org @ 2004-05-09 15:18 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-05-09 15:18 -------
No, it's not a regression -- we never detected this at least back to
2.95.
With respect to the testcase: they only seem to be in the CVS archive
since after the 3.4 branch was created. Giovanni added these files on
2004/02/17. They are not present on the 3.4 branch.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-05-09 15:18:22
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/15339] [DR217] Adding default arguments to function templates in redeclartions should be forbidden
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
` (8 preceding siblings ...)
2004-05-09 15:18 ` bangerth at dealii dot org
@ 2004-07-13 20:13 ` giovannibajo at libero dot it
2004-07-13 20:14 ` giovannibajo at libero dot it
10 siblings, 0 replies; 16+ 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 -------
*** Bug 11540 has been marked as a duplicate of this bug. ***
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |philippe dot haution at
| |mines-paris dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/15339] [DR217] Adding default arguments to function templates in redeclartions should be forbidden
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
` (9 preceding siblings ...)
2004-07-13 20:13 ` giovannibajo at libero dot it
@ 2004-07-13 20:14 ` giovannibajo at libero dot it
10 siblings, 0 replies; 16+ messages in thread
From: giovannibajo at libero dot it @ 2004-07-13 20:14 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-07-13 20:14 -------
PR 11827 contains a small patch for this bug by Jakub, but it doesn't look OK
(it wait for instantiation).
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15339
^ permalink raw reply [flat|nested] 16+ messages in thread