2008/5/21 Andy H <[EMAIL PROTECTED]>: > Thanks for explanation and help > > But this leave me with the conclusion that one of the following must be > wrong: > > signed char xi; > > xi = (int) (unsigned short int) sc; /* testcase 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*/ > > Following your logic, (long).... appears to be wrong. Yet for i686 the first > case (int)..... generates PASS with expected warning and that would seem > similar.
My logic may be wrong. There may be something I am missing here. Although I tried all possible values of signed char and both sc and xi appear to end up with the same value (no matter whether you use int or long, since by the text of the warning, it seems it is dropped anyway). I would call it a bug, perhaps it is one of the bugs I mentioned before. To know what is really going on you would have to step in c-common.c (conversion_warning) and see why the cast is not dropped. Perhaps get_unwidened() is not the function that should be used there. Perhaps we should use get_narrower() somehow. Or perhaps the whole expression has been transformed and folded into something different before it reaches that point. I am sorry but I don't have time to look deeply into this. Please, open a bug report and add a testcase (better if it can be tested in i686). I hope somebody else can take a look at it. Thanks, Manuel.