Wind River Support Network

HomeDefectsLIN6-9719
Fixed

LIN6-9719 : WR gcc 6.0.0.16: Missing warning

Created: Apr 13, 2015    Updated: Dec 3, 2018
Resolved Date: Jun 17, 2015
Found In Version: 6.0.0.16
Severity: Standard
Applicable for: Wind River Linux 6
Component/s: Toolchain

Description

GCC 4.8 introduced aggressive loop optimizations which will break some loops if the code has undefined behavior. We have previously reported that gcc should output a warning in this case and that fix is included in WR 6.0.0.16. We have however discovered a new case in which aggressive loop optimizations will break a loop without issuing a warning. 

The attached code contains a function which removes an item from a list and moves down all trailing items. The expected result is a shorter list but when the optimization is activated, the size of the list is not decreased. The example is compiled with “i686-wrs-linux-gnu-gcc --sysroot <sysroot> -m32 -Wall -O3 -o loop loop.c” and the problem goes away when adding “-fno-aggressive-loop-optimizations”. The behavior is the same when compiling for ARM. We consider it a bug that no compiler warning is shown in this example. 

Expected output: 
4 items 
Item 0: 1 
Item 1: 2 
Item 2: 3 
Item 3: 4 
3 items 
Item 0: 2 
Item 1: 3 
Item 2: 4 

Actual output: 
4 items 
Item 0: 1 
Item 1: 2 
Item 2: 3 
Item 3: 4 
4 items 
Item 0: 2 
Item 1: 3 
Item 2: 4 
Item 3: 4 

Other Downloads


Live chat
Online