Hi all, I was on stackoverflow when I came across this question: http://stackoverflow.com/questions/4173107/llvm-gcc-stdallocator-bug. It's causing a segmentation fault when compiled with llvm-g++ but not when compiled with g++. It also works under OS X but not under Ubuntu 10.10. I've reduced a test case down to the following: #include <vector> struct blub {}; struct intvec : public std::vector<int>, public blub {}; int main() { intvec d; intvec e(d); } The last interesting comment is that if I add the following copy constructor (as well as a default constructor), it works: intvec(const intvec & other) : std::vector<int>(other) {} If I add this copy constructor (and the same default constructor), it will still seg fault. intvec(const intvec & other) : std::vector<int>(other), blub(other) {} Anyone have any ideas about this? Thanks, Bill Lynch -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101113/8ad6beda/attachment.html>
Another short comment about this, adding a virtual destructor also keeps the segmentation fault from occurring. On Sat, Nov 13, 2010 at 11:41 AM, William Lynch <wlynch at wlynch.cx> wrote:> Hi all, > > I was on stackoverflow when I came across this question: > http://stackoverflow.com/questions/4173107/llvm-gcc-stdallocator-bug. It's > causing a segmentation fault when compiled with llvm-g++ but not when > compiled with g++. It also works under OS X but not under Ubuntu 10.10. > > I've reduced a test case down to the following: > > #include <vector> > > struct blub {}; > struct intvec : public std::vector<int>, public blub {}; > > int main() { > intvec d; > intvec e(d); > } > > The last interesting comment is that if I add the following copy > constructor (as well as a default constructor), it works: > > intvec(const intvec & other) : std::vector<int>(other) > {} > > If I add this copy constructor (and the same default constructor), it will > still seg fault. > > intvec(const intvec & other) : std::vector<int>(other), blub(other) > {} > > > Anyone have any ideas about this? > Thanks, > Bill Lynch >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101113/cd72b225/attachment.html>
Hi Bill,> I was on stackoverflow when I came across this question: > http://stackoverflow.com/questions/4173107/llvm-gcc-stdallocator-bug. It's > causing a segmentation fault when compiled with llvm-g++ but not when compiled > with g++. It also works under OS X but not under Ubuntu 10.10.I can't reproduce this with latest llvm-g++ from subversion on x86-64 linux. Ciao, Duncan.> > I've reduced a test case down to the following: > > #include <vector> > > struct blub {}; > struct intvec : public std::vector<int>, public blub {}; > > int main() { > intvec d; > intvec e(d); > } > > The last interesting comment is that if I add the following copy constructor (as > well as a default constructor), it works: > > intvec(const intvec & other) : std::vector<int>(other) > {} > > If I add this copy constructor (and the same default constructor), it will still > seg fault. > > intvec(const intvec & other) : std::vector<int>(other), blub(other) > {} > > > Anyone have any ideas about this? > Thanks, > Bill Lynch > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev