I came across this odd issue with testsuite test Wconversion-5.c and AVR target. I should get warning going from a unsigned value that is wider than signed result.

As I am not skilled in the art of the all conversions rules. I would appreciate some guidance before I report this as bug.

FYI AVR has 16 bit int, 16 bit short  int and 32 bit long.

I extracted the problematic line with a few variants and compiled -O0 and -Wconversion,

void foo(void)
{
  signed char sc;
  signed char xi;

xi = (int) (unsigned short int) sc; /* testcase NO WARNING - think this is bug*/
 xi =  (unsigned short int) sc;   /* NO WARNING - think this is bug*/
xi = (long) (unsigned short int) sc; /* warning: conversion to 'signed char' from 'short unsigned int' may alter its value - correct*/
 xi =  (long) ( short int) sc;    /* NO WARNING - correct */
 }

It would seem Wconversion:want to see 32bit result before it gives warning.
That can't be right - can it?

best regards



Reply via email to