On 18/08/16 00:44, Toshi Morita wrote:
> David Brown wrote:
>
>> No, it would not be valid. Declaring pfoo as a "const int*" tells the
>> compiler "I will not change anything via this pointer - and you can
>> optimise based on that promise". It does /not/ tell the compiler "the
>> thing that th
use
2016-08-17
-
发件人:Toshi Morita
发送日期:2016-08-17 08:21
收件人:gcc@gcc.gnu.org
抄送:
主题:Possible missed optimization opportunity with const?
I was involved in a discussion over the semantics of "const" in C, and the
following code was posted:
#include
int foo = 0;
const in
for the code to print a:0, b: 0?
If so, is this a missed optimization opportunity?
No, it would not be valid. Declaring pfoo as a "const int*" tells the
compiler "I will not change anything via this pointer - and you can
optimise based on that promise". It does /not/ tell
Hello,
I've come across an issue when working on a smart pointer
implementation. Gcc does not seem to propagate constants enough, missing
some optimization opportunities. I don't think that this issue is
specific to smart pointers, so there might be other cases when gcc
generates suboptimal c