Fails to spot logical error

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

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

This bug affects 2 people
Affects Status Importance Assigned to Milestone
GNU ARM Embedded Toolchain

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:-


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
Leo Havmøller (leh-p) wrote :

I have created a minimal example for this. It has 2 functions: test1(), which does emit -Wlogical-op as expected, and test2(), where -Wlogical-op would be really nice to have.
The issue described is found in Silicon Labs EFM32 SDK, and can be seen here in line 197 and 203.

Leo Havmøller (leh-p) wrote :
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments