[Bug tree-optimization/82192] gcc produces incorrect code with -O2 and bit-field
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Tue Sep 12 15:55:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82192
--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Tue, 12 Sep 2017, vsevolod.livinskij at frtk dot ru wrote:
> struct struct_t {
> unsigned int memb : 13;
> };
>
> extern struct_t b;
> printf("%llu\n", b.memb);
unsigned int : 13 (promoted to int - I think C++ promotes
narrower-than-int bit-fields to int, though for C++ the bit-field width is
not considered part of the type) is not valid for printf %llu. You need
to explicitly cast to unsigned long long.
More information about the Gcc-bugs
mailing list