c++/8860: illegal constructor causes internal compiler error
a-hw@mail.ru
a-hw@mail.ru
Sat Dec 7 08:16:00 GMT 2002
>Number: 8860
>Category: c++
>Synopsis: illegal constructor causes internal compiler error
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Dec 07 08:16:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: a-hw@mail.ru
>Release: gcc (GCC) 3.2 (mingw special 20020817-1)
>Organization:
>Environment:
Win2K, MingGW 2.0.0 prebuilt binaries
>Description:
This code causes g++ to feel segmentation fault. I've replaced initializer for base class Smoother(size) with Smoother_Lookup(size):
template<typename Function>
class Smoother_Lookup : public Smoother {
public:
Smoother_Lookup(int size) : Smoother_Lookup(size), lookup(size) {
std::generate_n(lookup.begin(), size, Function(size));
}
int smooth(int r) { return lookup[r]; }
protected:
std::vector<int> lookup;
};
>How-To-Repeat:
Try to compile test.cpp:
make test.o
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="test.cpp"
Content-Disposition: inline; filename="test.cpp"
#include <vector>
class Smoother {
public:
Smoother(int size) : _size(size) { }
virtual ~Smoother() = 0;
virtual int smooth(int r) = 0;
protected:
int _size;
};
template<typename Function>
class Smoother_Lookup : public Smoother {
public:
Smoother_Lookup(int size) : Smoother_Lookup(size), lookup(size) {
std::generate_n(lookup.begin(), size, Function(size));
}
int smooth(int r) { return lookup[r]; }
protected:
std::vector<int> lookup;
};
struct Test {
int operator()() { return 0; }
};
int
f() {
Smoother_Lookup<Test> sl(1);
}
More information about the Gcc-bugs
mailing list