Bug 61509 - GCC miscompilation on ARM during RTL optimization when compiled with -O2
Summary: GCC miscompilation on ARM during RTL optimization when compiled with -O2
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.6.3
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: http://quentusrex.com/freeswitch-rasp...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-14 19:03 UTC by William King
Modified: 2016-07-30 06:16 UTC (History)
1 user (show)

See Also:
Host:
Target: arm
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-06-14 00:00:00


Attachments
Source file for switch_core_media.c (48.22 KB, text/x-csrc)
2014-06-14 20:15 UTC, William King
Details

Note You need to log in before you can comment on or make changes to this bug.
Description William King 2014-06-14 19:03:23 UTC
C code:
if(strcasecmp(var,"a")) 
else if(strcasecmp(var, "b") 

the second call to strcasecmp is being optimized out, and the control statement is effectively being treated as an if() else statement.

More detailed write up here: 
http://quentusrex.com/freeswitch-raspberrypi-gcc-compiler-bug.html

Debug files located here:
https://github.com/quentusrex/FS-6495/tree/master/gcc_debug_orig

The second call to strcasecmp is being removed in pass #200 during a DCE loop.
Comment 1 Andrew Pinski 2014-06-14 19:10:22 UTC
4.6.3 is no longer supported, can you try a newer compiler?  Also can you attach the preprocessed source?
Comment 2 William King 2014-06-14 20:15:02 UTC
Created attachment 32939 [details]
Source file for switch_core_media.c

Line 3356 is the strcasecmp that is being optimized out.
Comment 3 William King 2014-06-14 20:15:45 UTC
Line 7945 has the strcasecmp of the gcc output 'original' pass:
https://github.com/quentusrex/FS-6495/blob/master/gcc_debug_orig/switch_core_media.c.003t.original
Comment 4 Andrew Pinski 2014-06-14 22:26:31 UTC
(In reply to William King from comment #2)
> Created attachment 32939 [details]
> Source file for switch_core_media.c

This is the source and not the preprocessed source.
Comment 5 William King 2014-06-14 22:47:25 UTC
Preprocessed file located here:
http://quentusrex.com/switch_core_media.c.preprocessed
Comment 6 Richard Biener 2014-06-16 08:30:36 UTC
Still waiting for reporter to try a still supported compiler which would be
GCC 4.8.3 or 4.9.0.
Comment 7 William King 2014-06-17 15:00:17 UTC
While I haven't had a chance to run through more than a handful of call scenarios, building FreeSWITCH on the Raspberry Pi with GCC 4.9.0 does not have the same problem.
Comment 8 Andrew Pinski 2016-07-30 06:16:26 UTC
No feedback in over 2 years and it sounds like it was working now anyways.