Bug 76056 - g++ 2.96 segmentation fault in bastring ?
Summary: g++ 2.96 segmentation fault in bastring ?
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.1
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-10-16 10:26 UTC by Need Real Name
Modified: 2007-04-18 16:47 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2002-12-16 01:34:05 UTC
Embargoed:


Attachments (Terms of Use)

Description Need Real Name 2002-10-16 10:26:28 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.2-2 i686)

Description of problem:
The compiler gives a segmentation fault on a simple file containing a class and
a template with complicated template arguments but only when the <complex>
header is included.
#include <string>
#include <complex>

class PDO {
public:
  string name;
  PDO( string p_n) : name(p_n){}
};

PDO Divg( "div");

template< template<int> class G, template< template<int> class> class P>
P< G>  gradient( P< G> A){
  return P<G>( A);
}


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Compile the above code with g++ -c
2. The problem disappears by leaving out the <complex> header
3. The problem also disappears by commenting out either the construction of Divg
or the template
	

Actual Results:  Step 1 gives a segmentation fault during compilation and an
error message

Steps 2 and 3 give no messages

Expected Results:  If the code is erroneous, an error message without core dump,
but I think 
the code is correct

Additional info:

/usr/include/g++-3/std/bastring.h: In method `const charT 
*basic_string<charT, traits, Allocator>::data () const [with charT = 
char, traits = string_char_traits<char>, Allocator = 
__default_alloc_template<true, 0>]':
/usr/include/g++-3/std/bastring.cc:165:   instantiated from `basic_string<charT,
 traits, Allocator>::replace (unsigned int, unsigned int, const charT *, unsigne
d int) [with charT = char, traits = string_char_traits<char>, Allocator = __defa
ult_alloc_template<true, 0>]'
/usr/include/g++-3/std/bastring.h:223:   instantiated from `basic_string<charT, 
traits, Allocator>::assign (const charT *, unsigned int) [with charT = char, tra
its = string_char_traits<char>, Allocator = __default_alloc_template<true, 0>]'
/usr/include/g++-3/std/bastring.h:225:   instantiated from `basic_string<charT, 
traits, Allocator>::assign (const charT *) [with charT = char, traits = string_c
har_traits<char>, Allocator = __default_alloc_template<true, 0>]'
/usr/include/g++-3/std/bastring.h:183:   instantiated from `basic_string<charT, 
traits, Allocator>::basic_string (const charT *) [with charT = char, traits = st
ring_char_traits<char>, Allocator = __default_alloc_template<true, 0>]'
buggy.C:10:   instantiated from here
/usr/include/g++-3/std/bastring.h:157: Internal error: Segmentation 
fault.
Please submit a full bug report.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.

Comment 1 Alan Cox 2002-12-16 01:34:05 UTC
g++ 3.2 correctly reports

x1.C:3: 'string' is used as a type, but is not defined as a type.
x1.C:4: parse error before `p_n'
x1.C:4: missing ';' before right brace
x1.C: In function `void __static_initialization_and_destruction_0(int, int)':
x1.C:7: no matching function for call to `PDO::PDO(const char[4])'
x1.C:1: candidates are: PDO::PDO()
x1.C:1:                 PDO::PDO(const PDO&)

and does not crash



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