Re: how to make gcc warn about arithmetic signed overflow

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

 



On 21 September 2013 18:42,  <wempwer@xxxxxxxxx> wrote:
>
> Hmm, I don't know too much about C++ but why would a C++ compiler
> produce a warning only if two operands were const? I learned that in C
> `const' modifier only means that I promise to the compiler that this
> variable will be read-only,

So the compiler knows that the values of ab and bc, because they must
always have the values they were initialized with.

If the compiler was smarter it would be able to also warn for
non-const values if it can prove that nothing has modified the
variables since they were initialized.

> its value can be changed using pointers

No, that's not true. You can't change the value of a const object in a
valid program.

> but the result is undefined and that const != constant expression.

In C++ a const of integral type is a constant expression.




[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