Issue Details (XML | Word | Printable)

Key: PCC-345
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Nicolas Joly
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

sizeof() should fail for incomplete type

Created: 09/May/11 07:42 PM   Updated: 11/May/11 10:13 PM
Component/s: Common code
Affects Version/s: None
Fix Version/s: None

NetBSD 5.99.51 NetBSD 5.99.51 (LANFEUST) #46: Mon May 9 11:21:30 CEST 2011 amd64
pcc 1.1.0.DEVEL 20110509 for x86_64-unknown-netbsd5.99.51,

 Description  « Hide
Calling sizeof() on an incomplete type should fail, but do not actually.

njoly@lanfeust [~]> cat sizeof.c
#include <stddef.h>
size_t len = sizeof(struct foo);
njoly@lanfeust [~]> pcc -c sizeof.c; echo $?
njoly@lanfeust [~]> gcc -c sizeof.c; echo $?
sizeof.c:2: error: invalid application of 'sizeof' to incomplete type 'struct foo'

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 11/May/11 10:13 PM
Fixed by not allowing size/align on undeclared structs.