Hi,
I've reported a segfault before in ASTRecordLayout::LayoutField(). There's a NULL pointer dereference if clang tries to calculate size of struct which contains incomplete type (eg. another struct which is declared but not defined). This patch should fix the problem and let clang abort on the appropriate assert instead.
BTW, some of the asserts in ASTContext::getTypeInfo() could be turned into simple compile errors because C99 forbids using sizeof operator on incomplete types.
When you apply this patch, you can close bug 2400. My problem will be fixed and the problem reported by Mr. Lopes is invalid (size_t is defined in <stddef.h> so its use in typedef on line 1 of the test case is not allowed without #include <stddef.h>).
Regards,
Martin Doucha
incomplete.patch (691 Bytes)
Hi,
I've reported a segfault before in ASTRecordLayout::LayoutField(). There's a NULL pointer dereference if clang tries to calculate size of struct which contains incomplete type (eg. another struct which is declared but not defined). This patch should fix the problem and let clang abort on the appropriate assert instead.
BTW, some of the asserts in ASTContext::getTypeInfo() could be turned into simple compile errors because C99 forbids using sizeof operator on incomplete types.
When you apply this patch, you can close bug 2400. My problem will be fixed and the problem reported by Mr. Lopes is invalid (size_t is defined in <stddef.h> so its use in typedef on line 1 of the test case is not allowed without #include <stddef.h>).
Fixed, thanks!
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080804/006896.html
Changing it to isIncompleteArrayType wasn't sufficient to fix the whole issue, but the rest was pretty easy. Thanks,
-Chris