[OCLUG-devel] ICFP Contest 2004

Stephen Crane scrane at cornerkitchenpeddler.com
Wed Jun 9 15:40:37 PDT 2004


On Wednesday, June 09, 2004 03:23 pm, you wrote:
> On Wed, 2004-06-09 at 15:17, Stephen Crane wrote:
> > On Wednesday, June 09, 2004 02:01 pm, you wrote:
> > > On Wed, 2004-06-09 at 14:02, Stephen Crane wrote:
> > > > I'm trying to understand something in the g++ compiler. If I turn on
> > > > the optimization (-O1) I get a SEGFAULT almost immediatly! Any clue
> > > > why this would happen? (I'm using the code attached to my original
> > > > post)
> > >
> > > Is it your code that is SEGFAULTing, or the compiler?
> >
> > Well, I tried it again and surprise, it worked. My code was segfaulting.
> > For some reason when I used the compiler in eclipse/CDT which used:
> > g++ -O3 -Wall -c -o simulator.o ../simulator.cpp
> > g++  -o ant_simulator     simulator.o
> > Or:
> > g++ -O0 -Wall -c -o simulator.o ../simulator.cpp
> > g++  -o ant_simulator     simulator.o
> > it wouldn't work, but if I used:
> > g++ -Wall -o ant_simulator simulator
> > It would work. Both commands apparently work now, don't know why. Any
> > reason why?
>
> I usually start blaming the hardware if it's the compiler segfaulting,
> but if it's your code, I'd use ulimit to make sure you get core dumps
> and start looking at what's inside them.

I'm not familiar with ulimit. What is it? I'm kinda new to *nix programming, 
so sorry if this is a dumb question.

> It's not unusual for optimizations to expose bugs that were previously
> hidden.



More information about the OCLUG-devel mailing list