PR# 18158 C compiler warning

Problem Report Summary
Submitter: manus_eiffel
Category: C Compilation
Priority: Medium
Date: 2012/04/09
Class: Bug
Severity: Serious
Number: 18158
Release: 7.1
Confidential: No
Status: Analyzed
Environment: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19
Synopsis: C compiler warning

The following code generates a warning at the C compilation level:

l_value: NATURAL_16

l_value := l_value // 10

The reason is that the generated code is like:

EIF_NATURAL_16 l_value;
EIF_NATURAL_16 l_div = (EIF_NATURAL_16) ((EIF_INTEGER_32) 10L);

l_value /= l_div;

Even though `l_value' and `l_div' are of the same type, it looks like internally the C compiler assumes that `l_value / l_div' generates a int that it then needs to convert to a EIF_NATURAL_16.

Replacing the code with:
l_value /= 10L;
fixes the warning in that particular case where it is a constant, but really 
To Reproduce
Using cl rev '14.00.50727.762 for x64' on Windows 7 x64.
Problem Report Interactions
From:alexk_es    Date:2012/04/10    Status: Analyzed    Download   
According to the C standard the arithmetic conversion takes place for other arithmetic operators as well. It means that the compiler should insert explicit type conversions for all the types except for INTEGER/NATURAL/REAL_32/64. For other types it cannot use increment/decrement operators and compound assignments that combine an arithmetic operation with an assignment into one operation.
I believe this can be fixed by checking the type of the expression in {ASSIGN_BL}.analyze_simple_assignment.