From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8C1073861001; Wed, 24 Apr 2024 01:48:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C1073861001 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713923338; bh=y8c1ILAQ/1j0Ig1AJ2m8n1HQQCLn/cpwu8yN7QDJW5A=; h=From:To:Subject:Date:From; b=mGn7yVFtKiBXnTVH9AJjqCpjcSevnAkpUkvtW97EwcseB655PuZ6tKcVv6DgN9AjN oZ65G4YH1BIsil/iV9DHu/jlE/7n09zesV6d9D5cO9hyzx6Mz2uTiwH1T9+l95/4JY 29xl4jIEQZFKk/q5hsZyZNYiRG2iAL3FcV7KnMNc= From: "mforney at mforney dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114831] New: typeof doesn't evaluate expression when it has variably modified type in some cases Date: Wed, 24 Apr 2024 01:48:58 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mforney at mforney dot org 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114831 Bug ID: 114831 Summary: typeof doesn't evaluate expression when it has variably modified type in some cases Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: mforney at mforney dot org Target Milestone: --- C23 introduced typeof, and 6.7.2.5p4 says > If the type of the operand is a variably modified type, the operand > is evaluated; otherwise, the operand is not evaluated. However, gcc doesn't evaluate the operand when it has variably modified typ= e in some cases. Consider the following program: #include int n =3D 1; int main(void) { int a[n], (*p)[n] =3D 0; typeof(puts("&a is variably-modified"), &a) p1; typeof(puts("p is variably-modified"), p) p2; typeof(puts("p1 is variably-modified"), p1) p3; typeof(puts("p2 is variably-modified"), p2) p4; } All four of the typeof operands have the same type, int (*)[n]. But when I = run this program it prints just: p is variably-modified p2 is variably-modified=