[Bug c/86092] global constant pointer optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86092 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #6 from Richard Biener --- kern_buff_p could be allocated to .rodata as well and thus a write traps.
[Bug c/86092] global constant pointer optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86092 --- Comment #5 from Srinivas Achary --- thank you Marc. What I have shown here is just an example sample code. But I have code which makes use of kern_buff_p variable in many place.If I use volatile that might reduce my code speed. Any how the kern_buff_p initial value is NULL and the variable have been allocated the memory during runtime without any issue. The problem is during compilation, the compiler optimizes all my conditional statements used with this constant pointers. Due to this, I am not able to run my code in New machines.
[Bug c/86092] global constant pointer optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86092 --- Comment #4 from Marc Glisse --- (In reply to Srinivas Achary from comment #2) > Is there any possibility to make this code work, Remove the 'const', or add 'volatile'. > without changing the variable attribute. -O0 > GCC-4 has no issue with this code. What special flags > have been included in the GCC-5. We don't add a new flag for every little optimization that might break invalid code.
[Bug c/86092] global constant pointer optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86092 Srinivas Achary changed: What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|INVALID |--- --- Comment #3 from Srinivas Achary --- I have tried disabling all ipa FLAGS
[Bug c/86092] global constant pointer optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86092 --- Comment #2 from Srinivas Achary --- Sorry that I am new to this. Is there any possibility to make this code work, without changing the variable attribute. GCC-4 has no issue with this code. What special flags have been included in the GCC-5. During disassemble the if(!kern_buff_p) -- is changed to if x0 is kern_buff_p mov x0, #0 This should be mov x0,[x0]
[Bug c/86092] global constant pointer optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86092 Andrew Pinski changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from Andrew Pinski --- static char* const kern_buff_p; You told the compiler it is constant and won't change values and then you changed the value behind its back. I think the kernel has a write once attribute instead.