https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39170

Florin Iucha <florin.iucha at amd dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |florin.iucha at amd dot com

--- Comment #17 from Florin Iucha <florin.iucha at amd dot com> ---
Warning if the code 'may alter its value' is one thing.

Can we have GCC at least not warn if it knows it will not alter the value?

For example, compiling

struct foo
{
   unsigned bar: 30;
   unsigned fill: 2;
};

struct foo test(unsigned value)
{
   struct foo foo;

   foo.bar = value >> 2;

   return foo;
}

This yields:

test.c: In function ‘test’:
test.c:11:14: warning: conversion to ‘unsigned int:30’ from ‘unsigned int’ may
alter its value [-Wconversion]
    foo.bar = value >> 2;
              ^

Tested with GCC 5.4.0 and 7.2.

Reply via email to