This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug lto/61741] wrong code by LTO on x86_64-linux-gnu
- From: "su at cs dot ucdavis.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 08 Jul 2014 05:35:54 +0000
- Subject: [Bug lto/61741] wrong code by LTO on x86_64-linux-gnu
- Auto-submitted: auto-generated
- References: <bug-61741-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61741
--- Comment #2 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Andi Kleen from comment #1)
> char c = 0;
> for (; a; a--)
> for (; c >= 0; c++);
>
> Don't you rely on signed overflow which is undefined?
No, there is no signed overflow since the variable c is a char so the
increments are performed on int first and then cast back to char: (char) ((int)
c + 1).
The same also holds for short.