This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: missing g++ warning about bad allocation
"Martin Ettl" <ettl.martin@gmx.de> 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