This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
my understanding of the C99 standard is that adding an integer and a pointer always results in a pointer. i'm not a compiler expert, but i would think that the rules that apply to adding a pointer and an integer of any signedness would be the same, and are different from the rules that would apply to adding signed or unsigned integers.My
understanding is that it shouldn't, because the real issue here is
pointer arithmetic and the resulting type should always be a pointer.
I'm not sure what you mean by that last statement.
Sorry about the string literal "Bug". This was just an artifact from the original program. I should have changed it to "optimization detected".I think we've already established that those tests that would print "BUG" aren't actually finding bugs in the compiler.
Iti think this depends on what you mean by "value".
is not correct to assume that adding a value to a char pointer
will wrap around in the same way as if you added a value to an
unsigned number.
You also cannot assume that adding a value toditto.
a signed number will cause it to wrap. (GCC had optimized away
checks for the latter already. There are now reports that many
other compilers may optimize away both tests.)
Are we in agreement on this? The fact that your example printsi agree that the optimization is allowed by C99. i think this is a quality of implementation issue, and that it would be preferable for gcc to emphasize security over performance, as might be expected.
"BUG!" seems to imply that it is invalid to optimize away these
tests, which it isn't.
this was only one of several solutions listed, and not the first one listed. You will see that the Compliant Solution provided in the referenced secure coding rule:I was under the impression that the only issue here is that there is a change in behavior. That's a very fine line to walk when many other compilers do this. In fact, you can run into the same change of behavior when switching from unoptimized debug versions to optimized release versions. Recommending not using a recent GCC as a possible remedy is dangerous (some would probably say irresponsible).
What you really mean is,i think we mean what we say, which is "*Avoid newer versions of gcc" and *"avoiding the use of gcc versions 4.2 and later." i don't see any verbiage that says "use a different compiler".
"Use an older GCC or some other compiler that is known not to
take advantage of this optimization."
P.S. Has anyone checked how far back in the line of Microsoftour tests shows that the 2005 version of the compiler does not perform this optimization. i have not yet tested a newer version of the compiler.
compilers you have to go to before they don't do this same
optimization
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |