public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15980] New: parse error caused by default initializer for a template type function argument
@ 2004-06-13 22:42 schoenebeck at software-engineering dot org
2004-06-13 22:55 ` [Bug c++/15980] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: schoenebeck at software-engineering dot org @ 2004-06-13 22:42 UTC (permalink / raw)
To: gcc-bugs
We encountered that gcc fails to compile with a parse error if a template
based function argument is assigned a default initializer in the function
prototype. Here is a stand alone test case for the exact problem:
#define BUG
template<typename A, typename B>
struct C {};
typedef C<int, int> C_int_int;
int w_typedef(C<int,int> arg = C_int_int()) {
return 0;
}
int wo_typedef(C<int,int> arg = C<int,int>()) {
return 0;
}
struct S {
int w_typedef(C_int_int arg = C_int_int()) {
return 0;
}
#ifdef BUG
int wo_typedef(C<int, int> arg = C<int,int>()) {
return 0;
}
#endif
};
int main(int argc, char* argv[]) {
w_typedef();
wo_typedef();
S s;
s.w_typedef();
#ifdef BUG
s.wo_typedef();
#endif
return 0;
}
It compiles fine when BUG is not defined though. This code failed with
gcc 3.2.2, 3.3.3 and also with 3.4, using various distributions (e.g. Debian
and RedHat).
--
Summary: parse error caused by default initializer for a template
type function argument
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: schoenebeck at software-engineering dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15980
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/15980] parse error caused by default initializer for a template type function argument
2004-06-13 22:42 [Bug c++/15980] New: parse error caused by default initializer for a template type function argument schoenebeck at software-engineering dot org
@ 2004-06-13 22:55 ` pinskia at gcc dot gnu dot org
2004-06-13 23:22 ` schoenebeck at software-engineering dot org
2004-06-13 23:26 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-13 22:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-13 22:55 -------
This is a dup of bug 57, one of the oldest bugs in GCC which is suspended because there is a DR report
about the problem and no can agrue of what the standard says.
A simple workaround is to do:
int wo_typedef(C<int, int> arg = (C<int,int>()))
note the parentheses around the default argument.
*** This bug has been marked as a duplicate of 57 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15980
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/15980] parse error caused by default initializer for a template type function argument
2004-06-13 22:42 [Bug c++/15980] New: parse error caused by default initializer for a template type function argument schoenebeck at software-engineering dot org
2004-06-13 22:55 ` [Bug c++/15980] " pinskia at gcc dot gnu dot org
@ 2004-06-13 23:22 ` schoenebeck at software-engineering dot org
2004-06-13 23:26 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: schoenebeck at software-engineering dot org @ 2004-06-13 23:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From schoenebeck at software-engineering dot org 2004-06-13 23:22 -------
Does it? Trying your proposed workaround gives me a "parse error before `;'
token" (currently tested with gcc 3.2.2).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15980
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/15980] parse error caused by default initializer for a template type function argument
2004-06-13 22:42 [Bug c++/15980] New: parse error caused by default initializer for a template type function argument schoenebeck at software-engineering dot org
2004-06-13 22:55 ` [Bug c++/15980] " pinskia at gcc dot gnu dot org
2004-06-13 23:22 ` schoenebeck at software-engineering dot org
@ 2004-06-13 23:26 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-13 23:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-13 23:26 -------
oh, the workaround only works on 3.4.0 and above then.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15980
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-06-13 23:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-13 22:42 [Bug c++/15980] New: parse error caused by default initializer for a template type function argument schoenebeck at software-engineering dot org
2004-06-13 22:55 ` [Bug c++/15980] " pinskia at gcc dot gnu dot org
2004-06-13 23:22 ` schoenebeck at software-engineering dot org
2004-06-13 23:26 ` pinskia 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).