Bug 19916 - [3.4/4.0/4.1 Regression] Segmentation fault in __static_initialization_and_destruction_0
Summary: [3.4/4.0/4.1 Regression] Segmentation fault in __static_initialization_and_de...
Status: VERIFIED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.4
: P2 normal
Target Milestone: 3.4.4
Assignee: Mark Mitchell
URL:
Keywords: wrong-code
Depends on: 19878
Blocks:
  Show dependency treegraph
 
Reported: 2005-02-11 22:56 UTC by Jon Grimm
Modified: 2005-07-23 22:41 UTC (History)
3 users (show)

See Also:
Host: ppc64-unknown-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-02-11 23:12:41


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Grimm 2005-02-11 22:56:24 UTC
The following testcase segfaults on 3.4.4 and 3.4.0, but runs to completion on
3.2.3.

Note this test won't even compile on mainline, so I don't know if the same
problem exists there.   See:
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19878
--------------------------------------------------------

//test.c
struct S {
  char k;
};

char const volatile S::* const p01 = &S::k;
int main(void)
{
  return  0;
}


--------------------------------------------------------  

/opt/gcc-nightly/3.4-20050211/bin/g++ -o test test.c 
./test 
Segmentation fault

------------------------------------------------

$ gdb ./test
(gdb) run
Starting program: /home/jgrimm/tmp/13930/test

Program received signal SIGSEGV, Segmentation fault.
0x10000474 in __static_initialization_and_destruction_0 (__initialize_p=1,
    __priority=65535) at g.c:5
5       char const volatile S::* const p01 = &S::k;

-----------------------------------------------

$ /opt/gcc-nightly/3.4-20050211/bin/g++ -v
Reading specs from
/home/gcc-nightly/3.4-20050211/bin/../lib/gcc/powerpc64-linux/3.4.4/specs
Configured with: /home/gccbuild/gcc_3.4_anoncvs/gcc/configure
--prefix=/opt/gcc-nightly/3.4-20050211 --build=powerpc64-linux
--host=powerpc64-linux --target=powerpc64-linux --with-cpu=default32
--with-as=/opt/gcc-nightly/binutils/bin/as
--with-ld=/opt/gcc-nightly/binutils/bin/ld --enable-threads=posix
--enable-shared --enable-__cxa_atexit --enable-languages=c,c++,f77,java,objc
Thread model: posix
gcc version 3.4.4 20050211 (prerelease)
Comment 1 Andrew Pinski 2005-02-11 23:12:41 UTC
Confirmed.
Comment 2 Andrew Pinski 2005-02-16 15:29:59 UTC
The behavior changed between 20030722 and 20030724.
Comment 3 Andrew Pinski 2005-02-16 15:33:03 UTC
I think this was caused by:
2003-07-22  Mark Mitchell  <mark@codesourcery.com>

        Eliminate use of POINTER_TYPE for pointers-to-members.
Comment 4 Mark Mitchell 2005-02-24 02:45:44 UTC
Now that 19878 has been fixed, we can see that this does in fact fail on the
mainline as well.
Comment 5 GCC Commits 2005-03-02 17:13:36 UTC
Subject: Bug 19916

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2005-03-02 17:13:10

Modified files:
	gcc            : ChangeLog varasm.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/init: ptrmem2.C 

Log message:
	PR c++/19916
	* varasm.c (initializer_constant_valid_p): Allow conversions
	between OFFSET_TYPEs.  Tidy.
	
	PR c++/19916
	* g++.dg/init/ptrmem2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7636&r2=2.7637
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&r1=1.477&r2=1.478
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5102&r2=1.5103
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/ptrmem2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 6 GCC Commits 2005-03-02 20:56:05 UTC
Subject: Bug 19916

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	mmitchel@gcc.gnu.org	2005-03-02 20:55:58

Modified files:
	gcc            : ChangeLog varasm.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/init: ptrmem2.C 

Log message:
	PR c++/19916
	* varasm.c (initializer_constant_valid_p): Allow conversions
	between OFFSET_TYPEs.  Tidy.
	
	PR c++/19916
	* g++.dg/init/ptrmem2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.18&r2=2.7592.2.19
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.477&r2=1.477.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.13&r2=1.5084.2.14
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/ptrmem2.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 7 GCC Commits 2005-03-02 20:58:01 UTC
Subject: Bug 19916

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2005-03-02 20:57:53

Modified files:
	gcc            : ChangeLog varasm.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/init: ptrmem2.C 

Log message:
	PR c++/19916
	* varasm.c (initializer_constant_valid_p): Allow conversions
	between OFFSET_TYPEs.  Tidy.
	
	PR c++/19916
	* g++.dg/init/ptrmem2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.809&r2=2.2326.2.810
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.405.2.6&r2=1.405.2.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.366&r2=1.3389.2.367
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/ptrmem2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1

Comment 8 Mark Mitchell 2005-03-02 21:04:04 UTC
Fixed in GCC 3.4.4.
Comment 9 Jon Grimm 2005-03-07 16:04:12 UTC
Verified. Thanks.