Re: missing g++ warning about bad allocation

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

 



Sorry for beeing so eager on this example, but i have compiled the testcase with following command:

g++ -W -Wall -Wextra -Wconversion -pedantic -o test test.cpp
test.cpp: In function ‘int main()’:
test.cpp:3: warning: unused variable ‘d’

And g++ does not warn about this implicit conversion. Have i missed something?

Best regards

Martin


-------- Original-Nachricht --------
> Datum: Thu, 02 Jul 2009 14:59:44 -0700
> Von: Ian Lance Taylor <iant@xxxxxxxxxx>
> An: "Martin Ettl" <ettl.martin@xxxxxx>
> CC: gcc-help@xxxxxxxxxxx
> Betreff: Re: missing g++  warning about bad allocation

> "Martin Ettl" <ettl.martin@xxxxxx> writes:
> 
> > i was not aware of -Wconversion flag. Never the less i was wondering
> > that this code was compilable. Because, allocting a negative amount of
> > memory does not make senense. Anyway, thanks for the help.
> 
> Since the value is unsigned, you aren't allocating a negative amount of
> memory.  The -100 is implicitly converted to an unsigned value (on a
> 32-bit machine, 0xffffff9c).  You are actually trying to allocate a very
> large amount of memory, which won't work, but isn't nonsensical.
> 
> -Wconversion warns about the implicit convertsion of the negative
> integer to an unsigned type.
> 
> Ian

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux