g++ 3.0.1: uninitialized int != 0
Markus Werle
numerical.simulation@web.de
Wed Aug 22 03:11:00 GMT 2001
Martin Kahlert wrote:
> On Wed, Aug 22, 2001 at 11:04:17AM +0200, Markus Werle wrote:
> > The integer k below does not default to zero with gcc-3.0.1
> > (Monday's version)
> > With gcc-3.0 this code here is OK.
>
> Why should it? In C (and i assume in C++, too) only static
> variables (and globals defined outside any funtion)
> are initialized by 0. Assuming anything more is a bug
> inside your code.
Ooops! You are right. I overlooked that the rule only applies to global,
namespace and local static objects. Sorry.
(Yes I have a few bugs in my code now).
g++ has a serious misfeature:
Using -Wall -pedantic -ansi on my code yields no warning at all.
Option -Wuninitialized should work without optimization and be included
into -Wall.
Even if the standard does not require a diagnostic here,
g++ _should_ have one.
Markus
More information about the Gcc-bugs
mailing list