Bug 149492

Summary: g++ seg fault for sizeof(std::vector)
Product: Red Hat Enterprise Linux 3 Reporter: Robert M. Day <dayrm>
Component: gcc3Assignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-05-18 13:42:38 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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

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>
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.

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.

http://rhn.redhat.com/errata/RHBA-2005-258.html