user
user

Reputation: 11

Can ARMCC generate a warning for implicit conversion?

I am trying to find the armcc equivalent of the gcc option that generate a warning if there is a sign mismatch when passing in integers into a function.

In gcc, these compiler options will generate an error message for the following code

gcc -Wconversion -Werror main.c -o main.exe

main.c

#include <stdint.h>

uint32_t div(uint32_t num1, uint32_t num2)
{
    return num1/num2;
}


int32_t main(void)
{

    int32_t a = -6;
    int32_t b = -12;

    div(b,a);
}

error message

main.c:15:9: error: conversion to 'uint32_t {aka unsigned int}' from 'int32_t {aka int}' may change the sign of the result [-Werror=sign-conversion]
     div(b,a);
         ^
main.c:15:11: error: conversion to 'uint32_t {aka unsigned int}' from 'int32_t {aka int}' may change the sign of the result [-Werror=sign-conversion]
     div(b,a);
           ^

However, in armcc there seems to be no equivalent that I know of. I tried the options --strict, promoting all warnings to errors, and even the option --translate_gcc to translate the gcc commands to armcc option but the code still compiled without error. In armcc the integer conversion error only appears when a signed number is directly assigned or passed where it should be unsigned:

uint32_t a = -6;
uint32_t b = -12;

div(-12,-6);

armcc error message

"../source/main.c", line 99: Error:  #68-D: integer conversion resulted in a change of sign
     uint32_t a = -6;
                  ^
"../source/main.c", line 100: Error:  #68-D: integer conversion resulted in a change of sign
     uint32_t b = -12;

Is there something I am not seeing or does arm's compiler not have support for this?

Upvotes: 1

Views: 46

Answers (0)

Related Questions