[Bug tree-optimization/82192] gcc produces incorrect code with -O2 and bit-field
vsevolod.livinskij at frtk dot ru
gcc-bugzilla@gcc.gnu.org
Tue Sep 12 16:50:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82192
--- Comment #4 from Vsevolod Livinskiy <vsevolod.livinskij at frtk dot ru> ---
(In reply to joseph@codesourcery.com from comment #3)
> 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.
printf("%llu\n", (unsigned long long int)b.memb)
doesn't eliminate the error
More information about the Gcc-bugs
mailing list