Bug 149492 - g++ seg fault for sizeof(std::vector)
Summary: g++ seg fault for sizeof(std::vector)
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc3   
(Show other bugs)
Version: 3.0
Hardware: i686
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2005-02-23 17:03 UTC by Robert M. Day
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-05-18 13:42:38 UTC
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
Red Hat Product Errata RHBA-2005:258 normal SHIPPED_LIVE gcc bug fix update 2005-05-18 04:00:00 UTC
GNU Compiler Collection 10558 None None None Never

Description Robert M. Day 2005-02-23 17:03:21 UTC
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 18:34:25 UTC
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 21:41:14 UTC
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 22:11:53 UTC
Thanks for the quick response and the explanation.

Comment 4 Jakub Jelinek 2005-03-01 12:13:56 UTC
Should be fixed in gcc-c++-3.2.3-52.

Comment 5 Tim Powers 2005-05-18 13:42:38 UTC
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.