Fails to spot logical error

Bug #1732237 reported by Mike Smith on 2017-11-14

This bug report will be marked for expiration in 56 days if no further activity occurs. (find out why)

6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU ARM Embedded Toolchain
Undecided
Unassigned

Bug Description

Using '6 2017-q2-update' and '6 2017-q1-update' from the ARM web site.

The following code from a library does not cause a warning with the '-Wlogical-op' warning option:-

      tmp = (DEVINFO->VDAC0CH1CAL && _DEVINFO_VDAC0CH1CAL_GAINERRTRIMCH1A_MASK)
            >> _DEVINFO_VDAC0CH1CAL_GAINERRTRIMCH1A_SHIFT;

Note the use of && instead of &.

The same code using GCC 4.9.3 supplied in the Ubuntu 16.04 package manager (i.e. 'arm-none-eabi-gcc (15:4.9.3+svn231177-1) 4.9.3 20150529 (prerelease)' to be precise) correctly gives a warning:-

em_vdac.c:197:35: warning: logical 'and' applied to non-boolean constant [-Wlogical-op]

The x86 version of GCC 5.4.0 also works correctly.

Its really a GCC problem, but it is worth pointing out since when it works this option is very useful.

Hi Mike,

Could you provide us with a standalone preprocessed testcase? Compiling with -save-temps and sending us the .i (or .ii if this is a C++ code) file would do this. Please also give the full command-line you used for compiling that testcase.

Best regards.

Changed in gcc-arm-embedded:
status: New → Incomplete
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers