From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3212E3858CDA; Tue, 30 Jan 2024 00:40:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3212E3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706575244; bh=/Y3Ii+rhR8JkStyJnXjX1TCEokvCvGjz1bN/pPdz/0s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mfo30r5MMe1FXRBHrv8vMEiVfrcb9j0KwilHKBgsI2G+yBCBN8byvYlJ59ryVg3hQ 4kgkdKzTsvIbwDn45gVxISKIeAT7HzUxEb9HjWiQFnfuzm8Ud+26hd4XAVcRqtOnIU IqervejAB4o3jEmmDrNpOEphlbqHDiFt2q7MDBkE= From: "matheus.a.m.moreira at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/112840] feature request: warn on incorrect tagged union value access Date: Tue, 30 Jan 2024 00:40:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: matheus.a.m.moreira at gmail dot com 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: Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112840 --- Comment #3 from Matheus Afonso Martins Moreira --- (In reply to uecker from comment #2) > I would go for a more generic feature where one can specify some invarian= t / > condition that needs be true when a member of a struct / union is accesse= d. So the proposed solution is a guard(expr) attribute that causes the compile= r to warn the developer if it can't statically determine that expr is true in the appropriate context. This would be great!! Much more flexible than the tag attribute I proposed.= How can we make it happen? I've never hacked on GCC before.=