On Jul 8, 12:32 am, Rares Vernica <ra...@ics.uci.edu> wrote:
> Rares Vernica <ra...@ics.uci.edu> writes:
> > I compile my code with g++ (GCC) 4.1.2. My code runs just
> > fine if I use the -O2 optimization flag. valgrind does not
> > report any memory leak.
> > When I use the -O3 flag, everything falls apart. The program
> > reports Segmentation fault. valgrind reports some Invalid
> > read.
> > Moreover, if I cout something near the line for which
> > valgrind reports the invalid read, then everything works
> > fine, no more segmentation faults or invalid reads.
> It was a bug in my code.
Now it works fine with -O3.
> Still, I am a little bit confused how the bug generated a
> segmentation fault only with -O3.
The generated code will be different according to the
optimization level. What the differences may be, we can only
speculate, not having seen your code, nor knowing what error
you'd made.
--
James Kanze (GABI Software) email:
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34