[Bug c++/70558] New: POD datatype array crash in initialization when using optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70558 Bug ID: 70558 Summary: POD datatype array crash in initialization when using optimization Product: gcc Version: 5.2.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hlprasu at gmail dot com Target Milestone: --- Created attachment 38197 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38197=edit Contains example code to reproduce this problem I have created a simple POD class named Double, which encapsulates 'double' type so that comparison operators can be handled in a numerically correct fashion. This is in the attached .tar.gz file. My problem is that if a create a fixed array with it and try to initialize all elements in a single statement then it crashes only when optimization is enabled. E.g.: Double v[3]; v[0] = v[1] = v[2] = 0.0; // <- crash here with -O or -O2 or -O3 Funnily enough, this does not crash if you do v[0] = 0.0; v[1] = 0.0; v[2] = 0.0; To reproduce this error, 1. Untar the attached file and go to the directory tar -xvzf double-pod-crash.tar.gz cd double-pod-crash/ 2. Run 'make' and execute the test file. make ./test # <- This segfaults at the above statement I saw the crash to be at the above statement by using gdb after recompiling with -g option. Please let me know a solution to this problem.
[Bug libstdc++/41949] std::endl documentation contains bad link
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41949 Prasad H. L. hlprasu at gmail dot com changed: What|Removed |Added CC||hlprasu at gmail dot com --- Comment #4 from Prasad H. L. hlprasu at gmail dot com --- (In reply to Jonathan Wakely from comment #3) Fixed for 4.5.0 The link seems to be broken again. Could you please fix it?
[Bug c++/44855] Static members not initialised in explicit template instances of library
--- Comment #6 from hlprasu at gmail dot com 2010-07-25 06:35 --- Subject: Re: Static members not initialised in explicit template instances of library Output of gcc -v is given below. I'm using Fedora 13 (with updates till July 24, 2010). The error still persists. === Using built-in specs. Target: i686-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-redhat-linux Thread model: posix gcc version 4.4.4 20100630 (Red Hat 4.4.4-10) (GCC) === On 25 July 2010 07:43, pinskia at gcc dot gnu dot org gcc-bugzi...@gcc.gnu.org wrote: --- Comment #5 from pinskia at gcc dot gnu dot org  2010-07-25 02:13 --- Works for me on the trunk and in 4.3.2. Can you give the output of gcc -v? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44855
[Bug c++/44855] New: Static members not initialised in explicit template instances of library
Consider the following C++ source code files = testLib.h === #include stdexcept #include iostream #define DEBUG1(X) std::coutX; typedef int IndexType; namespace Upagraha { templatetypename X,int Size class CompileTimeFixedSizeData { protected: X _data[Size]; //! The storage of the data static IndexType _size; //! The size of the data. public: CompileTimeFixedSizeData() { DEBUG1(Template value = Size std::endl); DEBUG1(Static variable value = _size std::endl); } virtual ~CompileTimeFixedSizeData() {} }; //setting the value of _size, which is static templatetypename X,int Size IndexType CompileTimeFixedSizeDataX,Size::_size=Size; /** Create an instance of CompileTimeFixedSizeData and associated functions. */ #define COMPILE_TIME_FIXED_SIZE_DATA_INSTANCE(TYPE,SIZE) \ template class CompileTimeFixedSizeDataTYPE,SIZE; } = testLib.cpp === #include testLib.h namespace Upagraha { COMPILE_TIME_FIXED_SIZE_DATA_INSTANCE(double,3) } = main.cpp === #include testLib.h namespace Upagraha { //extern template class CompileTimeFixedSizeDatadouble,3; // FIXME: Uncomment to see a change in behavior } int main() { Upagraha::CompileTimeFixedSizeDatadouble,3 a; } = makefile === #OPTIONS=-rdynamic -fno-implicit-templates -fPIC OPTIONS=-rdynamic -fno-implicit-templates # FIXME: Uncomment the top one to see change in behaviour test:libtestLib.so testLib.h main.cpp g++ $(OPTIONS) $(TOPTIONS) main.cpp -L${PWD} -ltestLib -o main libtestLib.so: testLib.cpp testLib.h g++ $(OPTIONS) $(TOPTIONS) -shared testLib.cpp -o libtestLib.so clean: rm main libtestLib.so *~ Put the above four files in same the directory and do the following *) make *) export LD_LIBRARY_PATH=$PWD *) ./main You'll see the output as = Template value = 3 Static variable value = 0 = Now, follow either of the two FIXMEs and build the program and run to get = Template value = 3 Static variable value = 3 = Why this difference in behaviour in initialisation of static variable Upagraha::CompileTimeFixedSizeDataX,Size::_size? Could somebody please explain this? -- Summary: Static members not initialised in explicit template instances of library Product: gcc Version: 4.4.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hlprasu at gmail dot com GCC build triplet: i686-redhat-linux GCC host triplet: i686-redhat-linux GCC target triplet: i686-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44855
[Bug c++/44855] Static members not initialised in explicit template instances of library
--- Comment #1 from hlprasu at gmail dot com 2010-07-07 07:22 --- Created an attachment (id=21120) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21120action=view) The test case attached To simplify the task of whomsoever who wants to see the behaviour, all the files mentioned in my previous post is packaged in a tar.bz2 file attached here. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44855
[Bug c++/44855] Static members not initialised in explicit template instances of library
--- Comment #3 from hlprasu at gmail dot com 2010-07-07 09:30 --- Subject: Re: Static members not initialised in explicit template instances of library But, as I know, no where is it mentioned to be necessary for static member initialisation. Why should the compiler allow for such a subtle error? Or is this documented somewhere? Besides this issue, I've not faced any other problem in using shared library by not using -fPIC. Could you please point out the necessary implications that I am missing here? On 7 July 2010 14:48, redi at gcc dot gnu dot org gcc-bugzi...@gcc.gnu.org wrote: --- Comment #2 from redi at gcc dot gnu dot org  2010-07-07 09:18 --- You need to use -fPIC for a shared object, so the version without that is not valid. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44855