From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.3) Gecko/20040924 Description of problem: This C++ code: // START CODE #include <iostream> #include <vector> main() { std::cout << sizeof(std::vector) << endl; } // END CODE causes a seg fault when compiled as follows; command$ g++ sizeofvec.cpp sizeofvec.cpp: In function `int main()': sizeofvec.cpp:6: internal error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions. Version-Release number of selected component (if applicable): gcc-c++-3.2.3-49 How reproducible: Always Steps to Reproduce: 1. Compile the code shown above. 2. 3. Actual Results: Seq fault with error message as shown above. Expected Results: Compilation (or more informative error message if code is bad). Additional info: My system: command$ uname -a Linux ***** 2.4.21-27.0.1.ELsmp #1 SMP Mon Dec 20 18:47:45 EST 2004 i686 i686 i386 GNU/Linux gcc version: command$ g++ -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-49)
That testcase is invalid, std::vector is a template, so you need to supply template arguments for it. You want something like this: #include <iostream> #include <vector> int main () { std::cout << sizeof(std::vector<int>) << std::endl; } G++ 3.4.x and GCC HEAD correctly diagnose this as an error: g++ -o /tmp/149492{,.C} /tmp/149492.C: In function `int main()': /tmp/149492.C:6: error: missing template arguments before ')' token 3.3.x issues diagnostic instead of segfaulting too, so I'll look into fixing this.
This was apparently fixed by PR c++/10558 fix on gcc-3_3-branch and a backported fix for that seems to fix it on gcc-3_2-rhl8-branch as well. Will test some more and probably include in RHEL3 U5.
Thanks for the quick response and the explanation.
Should be fixed in gcc-c++-3.2.3-52.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2005-258.html