Bug 18391 - internal error: Segmentation fault for valid code segment
Summary: internal error: Segmentation fault for valid code segment
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: 3.3
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-09 06:12 UTC by Arvind Sachdeva
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed file demonstrating the crash. (418 bytes, text/plain)
2004-11-09 06:15 UTC, Arvind Sachdeva
Details
when compiled with -v -save-temps (867 bytes, text/plain)
2004-11-09 06:16 UTC, Arvind Sachdeva
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arvind Sachdeva 2004-11-09 06:12:28 UTC
Try to compile the following code in a cpp file, gcc crashes. Working on Redhat 7.2.

#include <assert.h>

#define b 5
int f;
int foobar(int foo, int bar = (assert(f>=b), funcPtr)(), int foob=some_int);

Reading specs from
/shared/i80386linux/compiler/gcc3.2/linux2.4/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs
Configured with: ../configure
--prefix=/user/unicore/i80386linux/compiler/gcc3.2/linux2.4
--enable-languages=c,c++ --enable-threads=posix --enable-shared
--enable-__cxa_atexit
Thread model: posix
gcc version 3.2
Comment 1 Arvind Sachdeva 2004-11-09 06:15:26 UTC
Created attachment 7496 [details]
Preprocessed file demonstrating the crash.

It was just 48 lines, I havent bzip'd it
Comment 2 Arvind Sachdeva 2004-11-09 06:16:56 UTC
Created attachment 7497 [details]
when compiled with -v -save-temps
Comment 3 Andrew Pinski 2004-11-09 06:20:48 UTC
Fixed already in 3.3.
Comment 4 Arvind Sachdeva 2004-11-09 06:39:25 UTC
Subject: Re:  internal error: Segmentation fault for valid code segment

Was this bug filed earlier ? if yes, please send me the original bug number.

Thanks
-Arvind Sachdeva.


On 9 Nov 2004 06:20:51 -0000, pinskia at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
> 
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-09 06:20 -------
> Fixed already in 3.3.
> 
> --
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>            Severity|critical                    |normal
>              Status|UNCONFIRMED                 |RESOLVED
>          Resolution|                            |FIXED
>    Target Milestone|---                         |3.3
> 
> 
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18391
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
> You are on the CC list for the bug, or are watching someone who is.
>
Comment 5 Arvind Sachdeva 2004-11-09 09:26:07 UTC
The following code also crashes. Can somebody suggest a workaround while I am
using gcc 3.2

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

extern bool cond;

int (*funcPtr)();
#define printf 

int foobar(int foo, int bar = ((cond?funcPtr:(fprintf(stderr, "problem at
%s:%s\n", __FILE__, __LINE__), abort()))()), int foob=8);
Comment 6 Arvind Sachdeva 2004-11-09 09:28:00 UTC
I am planning to use the following code as workaround, which does not crash.

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

extern bool cond;

typedef int (*FuncPtr)();

FuncPtr funcPtr;

int foobar(int foo, int bar = ((cond?funcPtr:(fprintf(stderr, "problem at
%s:%s\n", __FILE__, __LINE__), (FuncPtr)0))()), int foob=8);
Comment 7 Andrew Pinski 2004-11-09 12:55:30 UTC
3.2.x is so old and not maintained any more and ther other one is fixed also already in 3.3, I think it is 
time to update.