Bug 44257

Summary: typeof(*(struct undefined *)) fails to compile
Product: gcc Reporter: rusty
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs
Priority: P3    
Version: 4.4.3   
Target Milestone: 10.0   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88827
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:

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).