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
2024-05-18 11:54 ` [Bug c/114831] " uecker at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages 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] 4+ messages in thread
* [Bug c/114831] typeof doesn't evaluate expression when it has variably modified type in some cases
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
@ 2024-05-18 11:54 ` uecker at gcc dot gnu.org
2024-05-18 20:21 ` muecker at gwdg dot de
2024-05-24 15:02 ` cvs-commit at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: uecker at gcc dot gnu.org @ 2024-05-18 11:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114831
uecker at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-05-18
CC| |uecker at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from uecker at gcc dot gnu.org ---
Confirmed.
We need to propagate C_TYPE_VARIABLY_MODIFIED correctly for address of an
array-to-pointer-decay.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/114831] typeof doesn't evaluate expression when it has variably modified type in some cases
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
2024-05-18 11:54 ` [Bug c/114831] " uecker at gcc dot gnu.org
@ 2024-05-18 20:21 ` muecker at gwdg dot de
2024-05-24 15:02 ` cvs-commit at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: muecker at gwdg dot de @ 2024-05-18 20:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114831
Martin Uecker <muecker at gwdg dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |muecker at gwdg dot de
--- Comment #2 from Martin Uecker <muecker at gwdg dot de> ---
PATCH: https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652089.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/114831] typeof doesn't evaluate expression when it has variably modified type in some cases
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
2024-05-18 11:54 ` [Bug c/114831] " uecker at gcc dot gnu.org
2024-05-18 20:21 ` muecker at gwdg dot de
@ 2024-05-24 15:02 ` cvs-commit at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-24 15:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114831
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Uecker <uecker@gcc.gnu.org>:
https://gcc.gnu.org/g:9f1798c1a93257526196a3c19828e40fb28ac551
commit r15-825-g9f1798c1a93257526196a3c19828e40fb28ac551
Author: Martin Uecker <uecker@tugraz.at>
Date: Sat May 18 14:40:02 2024 +0200
c: Fix for some variably modified types not being recognized [PR114831]
We did not evaluate expressions with variably modified types correctly
in typeof and did not produce warnings when jumping over declarations
using typeof. After addressof or array-to-pointer decay we construct
new pointer types that have to be marked variably modified if the pointer
target is variably modified.
2024-05-18 Martin Uecker <uecker@tugraz.at>
PR c/114831
gcc/c/
* c-typeck.cc (array_to_pointer_conversion, build_unary_op):
Propagate flag to pointer target.
gcc/testsuite/
* gcc.dg/pr114831-1.c: New test.
* gcc.dg/pr114831-2.c: New test.
* gcc.dg/gnu23-varmod-1.c: New test.
* gcc.dg/gnu23-varmod-2.c: New test.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-24 15:02 UTC | newest]
Thread overview: 4+ messages (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
2024-05-18 11:54 ` [Bug c/114831] " uecker at gcc dot gnu.org
2024-05-18 20:21 ` muecker at gwdg dot de
2024-05-24 15:02 ` cvs-commit at gcc dot gnu.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).