Re: missing g++ warning about bad allocation

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

 



"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

[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