[cfe-dev] Constants.cpp assertion raised
    Chris Lattner 
    clattner at apple.com
       
    Wed Jan  9 13:14:17 PST 2008
    
    
  
On Jan 9, 2008, at 1:00 AM, Michael Zolda wrote:
> Here is another piece of code that causes a crash (current SVN  
> version):
>
> typedef struct {
>  unsigned char c;
> } t;
>
> const t x = { 1 };
This looks like the "struct initializers aren't fully implemented"  
issue.  Consider this:
typedef struct {
  unsigned char c;
} t;
void foo() {
const t x = { 1 };
}
$ clang -ast-dump crash.c
void foo()
(CompoundStmt 0x806460 <crash.c:5:12, line:7:1>
   (DeclStmt 0x806450 <:0:0>
     0x8062f0 "t const x =
       (InitListExpr 0x806430 <crash.c:6:13, col:17> 't const':'struct  
<anonymous>'
         (IntegerLiteral 0x806320 <col:15> 'int' 1))")
I'd expect the IntegerLiteral to be wrapped in an ImplicitCast that  
converts it from int to unsigned char.  Steve, can you please  
investigate then when you start work on struct initializers?
Thanks,
-Chris
    
    
More information about the cfe-dev
mailing list