On Mon, Nov 25, 2013 at 10:44:57AM +0100, Marek Polacek wrote: > The PR was fixed by Jakub in r205283, this patch merely adds a > testcase for it. Passed ubsan testsuite for -m32/-m64. > > Ok for trunk?
Can't you reduce it at least a little bit more? Like I doubt __attribute__ ((__visibility__ ("default"))) is needed to reproduce, I'd also think you could get rid of the namespaces, perhaps also const _Alloc& __a = _Alloc() argument? > 2013-11-25 Marek Polacek <pola...@redhat.com> > > testsuite/ > * g++.dg/ubsan/pr59250.C: New test. > > --- gcc/testsuite/g++.dg/ubsan/pr59250.C.mp3 2013-11-25 10:43:24.797315678 > +0100 > +++ gcc/testsuite/g++.dg/ubsan/pr59250.C 2013-11-25 10:41:24.859817636 > +0100 > @@ -0,0 +1,34 @@ > +// PR sanitizer/59250 > +// { dg-do compile } > +// { dg-options "-fsanitize=undefined" } > +// { dg-skip-if "" { *-*-* } { "-flto" } { "" } } > + > +namespace std __attribute__ ((__visibility__ ("default"))) { > + template<typename> class allocator; > + template<class _CharT> struct char_traits; > + template<typename _CharT, typename _Traits = char_traits<_CharT>, > + typename _Alloc = allocator<_CharT> > class basic_string; > + typedef basic_string<char> string; > +} > +namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { > + template<typename _Tp> class new_allocator { }; > +} > +namespace std __attribute__ ((__visibility__ ("default"))) { > + template<typename _Tp> class allocator: public > __gnu_cxx::new_allocator<_Tp> { }; > + template<typename _CharT, typename _Traits, typename _Alloc> class > basic_string { > + public: > + basic_string(const _CharT* __s, const _Alloc& __a = _Alloc()); > + }; > +} > +class FileImpl { }; > +class FileHandle { > + std::string fname; > + class FileImpl* impl; > + FileHandle (const char* fname); > +}; > +class NormalFile : public FileImpl { > + int fd; > +}; > +FileHandle::FileHandle (const char* fname) : fname(fname) { > + impl = new NormalFile(); > +} > > Marek Jakub