Bug 25851

Summary: Internal error: Segmentation fault.
Product: [Retired] Red Hat Linux Reporter: Dimitri Papadopoulos <dpo>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: high Docs Contact:
Priority: medium    
Version: 7.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: 2001-02-06 16:33:50 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 Dimitri Papadopoulos 2001-02-03 13:33:45 UTC
Hi,

Compile the following C code with GCC 2.96 + latest patches:

	void func(void)
	{
	  int i;
	#line 1 "/foo/foo.h"
	  if (1)
	    i = 1;
	  else
	    i
	#line 2
	    = 0;
	}

The compiler will segfault:
	$ gcc -c foo.c
	/foo/foo.h: In function `f':
	/foo/foo.h:2: Internal error: Segmentation fault.
	Please submit a full bug report.
	See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.

Of course the code is not correct but the compiler should not segfault.

Note: Similar code is generated by KAI C++. This prevents from compiling
with KAI C++ on Red Hat 7, or at least from getting meaningful error
messages from the GCC back-end.

Thanks,
Dimitri

Comment 1 Dimitri Papadopoulos 2001-02-03 13:59:41 UTC
Oh, I see now that the KAI C++ code is _not_ incorrect.
Actually it does not look like the code previously posted.
It looks like this:

	void func(void)
	{
	  int i;
	#line 1 "/foo/foo.h"
	  if (1) i = 1; else i
        #line 1
	    = 0;
	}

The code is really meant to hold in a single line. Now I have read
paragraph 16.4.3 of ISO C++ and it is not very clear what happens
in this special case. Unfortunately I don't have the ISO C standard
available here, so I cannot check in the ISO C standard.

In any case KAI C++ works fine with other compilers so I guess this
should be fixed in GCC.

Dimitri


Comment 2 Jakub Jelinek 2001-02-06 16:33:46 UTC
I've fixed it in my tree, the fix will appear in gcc-2.96-75.