Fails to spot logical error

Bug #1732237 reported by Mike Smith on 2017-11-14
12
This bug affects 2 people
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
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 https://siliconlabs.github.io/Gecko_SDK_Doc/efm32gg/html/em__vdac_8c_source.html in line 197 and 203.

Leo Havmøller (leh-p) wrote :
Launchpad Janitor (janitor) wrote :

[Expired for GNU ARM Embedded Toolchain because there has been no activity for 60 days.]

Changed in gcc-arm-embedded:
status: Incomplete → Expired
Leo Havmøller (leh-p) wrote :

Expired, why?
The testcase was provided as requested.

Hi Leo, this is an automated action from Launchpad as the message suggest it. My apologies but I haven't had time to have a look at it. I'll try to reproduce it on latest GCC development tree in the next week or so which will decide what is the next action.

Best regards.

Leo Havmøller (leh-p) wrote :

Hi Thomas, do you still intend to look into this?
If so, please set status to something other than expired.

I can reproduce the two warnings with the testcase provided in comment #3 up to the 5-2016Q3 release but get only 1 warning (for test1) in 6-2016Q4.

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

Other bug subscribers

Bug attachments