Bug 44257 - typeof(*(struct undefined *)) fails to compile
Summary: typeof(*(struct undefined *)) fails to compile
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.4.3
: P3 normal
Target Milestone: 10.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-24 00:29 UTC by rusty
Modified: 2021-09-20 02:14 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 10.1.0
Known to fail: 5.1.0, 8.1.0, 9.1.0, 9.4.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rusty 2010-05-24 00:29:46 UTC
struct foo; 
typeof(struct foo) *p; // This is fine.
typeof(*p) *p2; // foo.c:5: error: dereferencing pointer to incomplete type

This is important, because AFAICT the only way to declare a const pointer for a given type is: "const typeof(*p) *" which doesn't work if p is a pointer to an undefined struct :(
Comment 1 Andrew Pinski 2021-09-20 02:14:38 UTC
Fixed for GCC 10+, most likely by r10-5166 (aka PR 88827).