From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B3844385B835; Fri, 17 Apr 2020 04:53:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3844385B835 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587099202; bh=dKy6vWV9ho8U+6cx7+T2UWO3/U5/+4rOsrsK1/rQ9hU=; h=From:To:Subject:Date:From; b=HP02jjyCh1wvpKd7B7AncFwZ4QPcszZGEogWpDihJr3v0y18mb7p3PKtWOKNPHHV1 z+2Q1cXAS4tRHOsmEkZ3BqanHvUVeLC/jxkY13fdWNpvdxPXV+SZzDGkfKg0w1wNhl E+PXbuohFkg80V2jRIYaZPmNO7Yhn+75oejAfJI4= From: "bugdal at aerifal dot cx" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/94631] New: Wrong codegen for arithmetic on bitfields Date: Fri, 17 Apr 2020 04:53:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bugdal at aerifal dot cx X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Apr 2020 04:53:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94631 Bug ID: 94631 Summary: Wrong codegen for arithmetic on bitfields Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: bugdal at aerifal dot cx Target Milestone: --- Test case: struct foo { unsigned long long low:12, hi:52; }; unsigned long long bar(struct foo *p) { return p->hi*4096; } Should generate only a mask off of the low bits, but gcc generates code to = mask off the low 12 bits and the high 12 bits (reducing the result to 52 bits). Presumably GCC is interpreting the expression p->hi as having a phantom type that's only 52 bits wide, rather than having type unsigned long long. clang/LLVM compiles it correctly. I don't believe there's any language in the standard supporting what GCC is doing here.=