So, this is similar to this issue: int x = ...; if (x + CONSTANT < x) overflow(); GCC will optimize out the check completely because the standard says so. There is no arguing that GCC is in its right to do the optimization. However there are plenty of circumstances where this code is in fact valid (when the values of x and CONSTANT are controlled and the code is running on two's complement machine, etc). So, I am concerned about two things: * Are these optimizations really beneficial ? Do situations like the above occur in _correct_ code ? * Don't they make C a less useful language ? C is often regarded as high level assembler. When I write something, it should not be up to the compiler to second guess me.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds