Re: const + optimizations [WAS: Need C optimization help]

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

 



Modifying an object via a const lvalue is a constraint violation; any
program that does this is not a valid C program.

Is the compiler able to use that for optimizations (eg. hold
const variables in registers, etc) ?

Well, it's forbidden, GCC will give an error.

But I suppose you mean if GCC can use the const-ness of objects
to direct optimisation?  It can.

Modifying a const object via a non-const lvalue is undefined behaviour.

Is there a flag to forbid that ?

It's always forbidden, but it cannot always be detected; halting
problem and all that.


Segher



[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