help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Crash following optimisation goes away when inserting printf


From: Martin Franke
Subject: Crash following optimisation goes away when inserting printf
Date: Tue, 23 Jan 2007 17:30:46 +0000
User-agent: Thunderbird 1.5.0.4 (X11/20060623)

Hi everybody,

First post, so thanks a lot for reading, and, hopefully, replying!

When turning on optimisation (gcc 3.4.2, O2/Os -fno-strict-aliasing)
when compiling our multi-platform software (C/C++ mix, target now is an
embedded MIPS based platform) it segfaults, while it runs without a
problem when turning optimisations off. I still get quite a few compiler
warnings, so it is probably best to completely resolve them first.

Still, there is something that strikes me as odd, and I would like to
kindly ask if someone could shed some light on this. The crash occurs in
the initialisation routine of a certain module. Now, when inserting a
printf("bla") right at start-up in main() the crash goes away, removing
it makes it re-appear, so it is perfectly reproducible. The printf is in
a different object file than where the crash happens and quite a lot of
code is executed between the printf and the crash.

So my questions are:
- Is this a side-effect to be expected?
- How can the additional printf in one object file can have a
side-effect on the code in another object file? (Each source file is
compiled and optimised separately, so I guess it must happen during
linkage, but that's where my understanding hits the wall.)

Thanks again!

Martin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]