c++/7202: function arg of "int X(0)" causes seg fault in compiler
geb@attbi.com
geb@attbi.com
Wed Jul 3 13:26:00 GMT 2002
>Number: 7202
>Category: c++
>Synopsis: function arg of "int X(0)" causes seg fault in compiler
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Wed Jul 03 13:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Gary Barnes
>Release: 3.0.1
>Organization:
none
>Environment:
System: Linux smbear.attbi.com 2.4.3-20mdk #1 Sun Apr 15 23:03:10 CEST 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure --prefix=/usr/local
>Description:
Using g++ command, immediate internal error, segmentation fault.
Appears to be due to use of constructor for default value of function argument.
>How-To-Repeat:
This command line:
g++ -c foo.cc -o foo.o -g -MMD -frepo -ansi -pedantic -fshort-enums -W -Wall \
-Wundef -Wshadow -Wpointer_arith -Wbad-function-cast -Wcast-qual -Wcast-align \
-Wwrite-strings -Wconversion -Wsign-compare -Wredundant-decls \
-Wunreachable-code -Wmissing-declarations -Winline -fmessage-length=99999 \
-Werror
This is the source code in foo.cc:
template <class Arg>
class One {
public:
virtual int Func (int X (0));
};
template <class Arg>
int One <Arg>::Func (int X (0)) {
return 1;
}
>Fix:
Use
int X = int (0)
instead. I discovered this using a more complicated type of course, one that
had a nontrivial constructor, but the bug shows with int.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list