public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/114831] New: typeof doesn't evaluate expression when it has variably modified type in some cases
@ 2024-04-24  1:48 mforney at mforney dot org
  0 siblings, 0 replies; only message in thread
From: mforney at mforney dot org @ 2024-04-24  1:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114831

            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 type in
some cases.

Consider the following program:

#include <stdio.h>
int n = 1;
int main(void) {
        int a[n], (*p)[n] = 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-24  1:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-24  1:48 [Bug c/114831] New: typeof doesn't evaluate expression when it has variably modified type in some cases mforney at mforney dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).