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

Florian J. Weber <oss at florianjw dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |oss at florianjw dot de

--- Comment #9 from Florian J. Weber <oss at florianjw dot de> ---
While I agree that Olegs example shouldn't trigger the warnings, I believe that
it is different from the initial one, in that the intermediate types are ints
due to integer-promotion.

I do however have an example that is definitely broken and doesn't make any
sense by any metric:


using byte = unsigned char;

struct boxed_array {
        byte data[1];
        byte& get(){return data[0];}
        const byte& get()const{return data[0];}
};

void xor_blocks(boxed_array& lhs, const boxed_array& rhs) {
        // warns with current GCC 6.2 as distributed by Debian
        lhs.get() ^=  rhs.get();
        // does not warn:
        lhs.get() = lhs.get() ^ rhs.get();
}

int main() {}


I could accept the inverse, as the second case involves integer-promotion to
int, but this doesn't even happen in the first one, making this highly absurd
behavior.

Reply via email to