Bug 149492 - g++ seg fault for sizeof(std::vector)
g++ seg fault for sizeof(std::vector)
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc3 (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2005-02-23 12:03 EST by Robert M. Day
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-05-18 09:42:38 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
GNU Compiler Collection 10558 None None None Never

  None (edit)
Description Robert M. Day 2005-02-23 12:03:21 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.3)

Description of problem:
This C++ code:

#include <iostream>
#include <vector>
    std::cout << sizeof(std::vector) << endl;

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):

How reproducible:

Steps to Reproduce:
1. Compile the code shown above.

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
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-49)
Comment 1 Jakub Jelinek 2005-02-23 13:34:25 EST
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>
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
Comment 2 Jakub Jelinek 2005-02-23 16:41:14 EST
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.
Comment 3 Robert M. Day 2005-02-23 17:11:53 EST
Thanks for the quick response and the explanation.
Comment 4 Jakub Jelinek 2005-03-01 07:13:56 EST
Should be fixed in gcc-c++-3.2.3-52.
Comment 5 Tim Powers 2005-05-18 09:42:38 EDT
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.


Note You need to log in before you can comment on or make changes to this bug.