compiler/libec; ide/debugger: Fixed potentially uninitialized Operands
authorJerome St-Louis <jerome@ecere.com>
Thu, 8 May 2014 15:43:37 +0000 (11:43 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 8 May 2014 15:48:50 +0000 (11:48 -0400)
- Not setting the type of Operand unless a value was successfully assigned to it
- Checking the result of Get*
- Zeroing out the values where Get* is used as an extra safety

compiler/bootstrap/libec/bootstrap/pass15.c
compiler/libec/src/pass15.ec
ide/src/debugger/debugTools.ec

index d1f8365..d6b432d 100644 (file)
@@ -10647,8 +10647,6 @@ if(!type->_class->registered->dataType)
 type->_class->registered->dataType = ProcessTypeString(type->_class->registered->dataTypeString, 0x0);
 type = type->_class->registered->dataType;
 }
-op.kind = type->kind;
-op.type = exp->expType;
 if(exp->type == 3 && op.kind == 13)
 {
 op.ui64 = (uint64)exp->string;
@@ -10657,6 +10655,8 @@ op.ops = uint64Ops;
 }
 else if(exp->isConstant && exp->type == 2)
 {
+op.kind = type->kind;
+op.type = exp->expType;
 switch(op.kind)
 {
 case 24:
@@ -11554,7 +11554,7 @@ break;
 }
 else
 {
-if(op1 && op2 && op1->kind != op2->kind)
+if(op1 && op2 && op1->type && op2->type && op1->kind != op2->kind)
 {
 if(Promote(op2, op1->kind, op1->type->isSigned))
 op2->kind = op1->kind, op2->ops = op1->ops;
@@ -12212,141 +12212,169 @@ case 24:
 case 1:
 if(type->isSigned)
 {
-char value;
+char value = (char)0;
 
-GetChar(e, &value);
+if(GetChar(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintChar(value);
 exp->type = 2;
 }
+}
 else
 {
-unsigned char value;
+unsigned char value = (unsigned char)0;
 
-GetUChar(e, &value);
+if(GetUChar(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintUChar(value);
 exp->type = 2;
 }
+}
 break;
 case 2:
 if(type->isSigned)
 {
-short value;
+short value = (short)0;
 
-GetShort(e, &value);
+if(GetShort(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintShort(value);
 exp->type = 2;
 }
+}
 else
 {
-unsigned short value;
+unsigned short value = (unsigned short)0;
 
-GetUShort(e, &value);
+if(GetUShort(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintUShort(value);
 exp->type = 2;
 }
+}
 break;
 case 3:
 if(type->isSigned)
 {
-int value;
+int value = 0;
 
-GetInt(e, &value);
+if(GetInt(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintInt(value);
 exp->type = 2;
 }
+}
 else
 {
-unsigned int value;
+unsigned int value = 0;
 
-GetUInt(e, &value);
+if(GetUInt(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintUInt(value);
 exp->type = 2;
 }
+}
 break;
 case 4:
 if(type->isSigned)
 {
-long long value;
+long long value = 0;
 
-GetInt64(e, &value);
+if(GetInt64(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintInt64(value);
 exp->type = 2;
 }
+}
 else
 {
-uint64 value;
+uint64 value = 0;
 
-GetUInt64(e, &value);
+if(GetUInt64(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintUInt64(value);
 exp->type = 2;
 }
+}
 break;
 case 22:
 if(type->isSigned)
 {
-intptr_t value;
+intptr_t value = 0;
 
-GetIntPtr(e, &value);
+if(GetIntPtr(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintInt64((long long)value);
 exp->type = 2;
 }
+}
 else
 {
-uintptr_t value;
+uintptr_t value = 0;
 
-GetUIntPtr(e, &value);
+if(GetUIntPtr(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintUInt64((uint64)value);
 exp->type = 2;
 }
+}
 break;
 case 23:
 if(type->isSigned)
 {
-ssize_t value;
+ssize_t value = 0;
 
-GetIntSize(e, &value);
+if(GetIntSize(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintInt64((long long)value);
 exp->type = 2;
 }
+}
 else
 {
-size_t value;
+size_t value = 0;
 
-GetUIntSize(e, &value);
+if(GetUIntSize(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintUInt64((uint64)value);
 exp->type = 2;
 }
+}
 break;
 case 6:
 {
-float value;
+float value = 0;
 
-GetFloat(e, &value);
+if(GetFloat(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintFloat(value);
 exp->type = 2;
+}
 break;
 }
 case 7:
 {
-double value;
+double value = 0;
 
-GetDouble(e, &value);
+if(GetDouble(e, &value))
+{
 FreeExpContents(exp);
 exp->constant = PrintDouble(value);
 exp->type = 2;
+}
 break;
 }
 }
index fbe0c1b..b1038c5 100644 (file)
@@ -4243,8 +4243,6 @@ public Operand GetOperand(Expression exp)
          type = type._class.registered.dataType;
 
       }
-      op.kind = type.kind;
-      op.type = exp.expType;
       if(exp.type == stringExp && op.kind == pointerType)
       {
          op.ui64 = (uint64)exp.string;
@@ -4253,6 +4251,9 @@ public Operand GetOperand(Expression exp)
       }
       else if(exp.isConstant && exp.type == constantExp)
       {
+         op.kind = type.kind;
+         op.type = exp.expType;
+
          switch(op.kind)
          {
             case _BoolType:
@@ -5150,7 +5151,7 @@ void CallOperator(Expression exp, Expression exp1, Expression exp2, Operand op1,
       }
       else
       {
-         if(op1 && op2 && op1.kind != op2.kind)
+         if(op1 && op2 && op1.type && op2.type && op1.kind != op2.kind)
          {
             if(Promote(op2, op1.kind, op1.type.isSigned))
                op2.kind = op1.kind, op2.ops = op1.ops;
@@ -5978,127 +5979,155 @@ void ComputeExpression(Expression exp)
                case charType:
                   if(type.isSigned)
                   {
-                     char value;
-                     GetChar(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintChar(value);
-                     exp.type = constantExp;
+                     char value = 0;
+                     if(GetChar(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintChar(value);
+                        exp.type = constantExp;
+                     }
                   }
                   else
                   {
-                     unsigned char value;
-                     GetUChar(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintUChar(value);
-                     exp.type = constantExp;
+                     unsigned char value = 0;
+                     if(GetUChar(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintUChar(value);
+                        exp.type = constantExp;
+                     }
                   }
                   break;
                case shortType:
                   if(type.isSigned)
                   {
-                     short value;
-                     GetShort(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintShort(value);
-                     exp.type = constantExp;
+                     short value = 0;
+                     if(GetShort(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintShort(value);
+                        exp.type = constantExp;
+                     }
                   }
                   else
                   {
-                     unsigned short value;
-                     GetUShort(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintUShort(value);
-                     exp.type = constantExp;
+                     unsigned short value = 0;
+                     if(GetUShort(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintUShort(value);
+                        exp.type = constantExp;
+                     }
                   }
                   break;
                case intType:
                   if(type.isSigned)
                   {
-                     int value;
-                     GetInt(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintInt(value);
-                     exp.type = constantExp;
+                     int value = 0;
+                     if(GetInt(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintInt(value);
+                        exp.type = constantExp;
+                     }
                   }
                   else
                   {
-                     unsigned int value;
-                     GetUInt(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintUInt(value);
-                     exp.type = constantExp;
+                     unsigned int value = 0;
+                     if(GetUInt(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintUInt(value);
+                        exp.type = constantExp;
+                     }
                   }
                   break;
                case int64Type:
                   if(type.isSigned)
                   {
-                     int64 value;
-                     GetInt64(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintInt64(value);
-                     exp.type = constantExp;
+                     int64 value = 0;
+                     if(GetInt64(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintInt64(value);
+                        exp.type = constantExp;
+                     }
                   }
                   else
                   {
-                     uint64 value;
-                     GetUInt64(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintUInt64(value);
-                     exp.type = constantExp;
+                     uint64 value = 0;
+                     if(GetUInt64(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintUInt64(value);
+                        exp.type = constantExp;
+                     }
                   }
                   break;
                case intPtrType:
                   if(type.isSigned)
                   {
-                     intptr value;
-                     GetIntPtr(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintInt64((int64)value);
-                     exp.type = constantExp;
+                     intptr value = 0;
+                     if(GetIntPtr(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintInt64((int64)value);
+                        exp.type = constantExp;
+                     }
                   }
                   else
                   {
-                     uintptr value;
-                     GetUIntPtr(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintUInt64((uint64)value);
-                     exp.type = constantExp;
+                     uintptr value = 0;
+                     if(GetUIntPtr(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintUInt64((uint64)value);
+                        exp.type = constantExp;
+                     }
                   }
                   break;
                case intSizeType:
                   if(type.isSigned)
                   {
-                     intsize value;
-                     GetIntSize(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintInt64((int64)value);
-                     exp.type = constantExp;
+                     intsize value = 0;
+                     if(GetIntSize(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintInt64((int64)value);
+                        exp.type = constantExp;
+                     }
                   }
                   else
                   {
-                     uintsize value;
-                     GetUIntSize(e, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintUInt64((uint64)value);
-                     exp.type = constantExp;
+                     uintsize value = 0;
+                     if(GetUIntSize(e, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintUInt64((uint64)value);
+                        exp.type = constantExp;
+                     }
                   }
                   break;
                case floatType:
                {
-                  float value;
-                  GetFloat(e, &value);
-                  FreeExpContents(exp);
-                  exp.constant = PrintFloat(value);
-                  exp.type = constantExp;
+                  float value = 0;
+                  if(GetFloat(e, &value))
+                  {
+                     FreeExpContents(exp);
+                     exp.constant = PrintFloat(value);
+                     exp.type = constantExp;
+                  }
                   break;
                }
                case doubleType:
                {
-                  double value;
-                  GetDouble(e, &value);
-                  FreeExpContents(exp);
-                  exp.constant = PrintDouble(value);
-                  exp.type = constantExp;
+                  double value = 0;
+                  if(GetDouble(e, &value))
+                  {
+                     FreeExpContents(exp);
+                     exp.constant = PrintDouble(value);
+                     exp.type = constantExp;
+                  }
                   break;
                }
             }
index 3cb6ef2..65be2fa 100644 (file)
@@ -518,16 +518,21 @@ void DebugComputeExpression(Expression exp)
                         }
                         else
                         {
-                           uint64 address;
+                           uint64 address = 0;
                            int size;
                            char format;
-                           if(exp1.expType.kind == structType)
+                           bool gotAddress = false;
+
+                           if(e.expType.kind == structType)
+                           {
                               address = exp1.address;
+                              gotAddress = true;
+                           }
                            else
-                              GetUInt64(exp1, &address);
+                              gotAddress = GetUInt64(e, &address);
                            size = ComputeTypeSize(exp.expType); //exp.expType.arrayType.size;
                            format = GetGdbFormatChar(exp.expType);
-                           if(format)
+                           if(gotAddress && format)
                            {
                               evaluation = Debugger::ReadMemory(address, size, format, &evalError);
                               switch(evalError)
@@ -570,7 +575,6 @@ void DebugComputeExpression(Expression exp)
                                     exp1.type = evalError;
                                     expError = exp1;
                                     break;
-
                               }
                            }
                            else
@@ -758,6 +762,7 @@ void DebugComputeExpression(Expression exp)
                         (type.kind == classType && type._class && type._class.registered &&
                            type._class.registered.type == enumClass))
                   {
+                     bool gotAddress = false;
                      uint64 address = 0, offset = 0;
                      Expression expNew, last = (Expression)exp.index.index->last;
                      Expression e = exp.index.exp;
@@ -777,15 +782,20 @@ void DebugComputeExpression(Expression exp)
 
                      //GetUInt(exp.index.exp, &address);
 
+                     GetUInt64(last, &offset);
+
                      // TOFIX: Check if it has address: TESTING
                      if(exp.index.exp.hasAddress && exp.index.exp.expType.kind == arrayType)
+                     {
                         address = exp.index.exp.address;
+                        gotAddress = true;
+                     }
                      else if(exp.index.exp.type == constantExp)
-                        GetUInt64(exp.index.exp, &address);
+                        gotAddress = GetUInt64(exp.index.exp, &address);
 
-                     GetUInt64(last, &offset);
                      //size = ComputeTypeSize(exp.expType.arrayType); //exp.expType.arrayType.size;
                      address += offset * size;
+
                      if(e.type == stringExp)
                      {
                         char * tmp = null;
@@ -827,7 +837,7 @@ void DebugComputeExpression(Expression exp)
                         FreeType(expType);
                         delete tmp;
                      }
-                     else if(exp.expType.kind == arrayType)
+                     else if(gotAddress && exp.expType.kind == arrayType)
                      {
                         FreeExpContents(exp);
                         exp.type = constantExp;
@@ -836,7 +846,7 @@ void DebugComputeExpression(Expression exp)
                         exp.address = address;
                         exp.hasAddress = true;
                      }
-                     else
+                     else if(gotAddress)
                      {
                         evaluation = Debugger::ReadMemory(address, size, format, &evalError);
                         switch(evalError)
@@ -882,6 +892,11 @@ void DebugComputeExpression(Expression exp)
                               break;
                         }
                      }
+                     else
+                     {
+                        FreeExpContents(exp);
+                        exp.type = unknownErrorExp;
+                     }
                   }
                }
             }
@@ -1213,7 +1228,7 @@ void DebugComputeExpression(Expression exp)
                         {
                            // Unfinished business...
                            BitMember bitMember = (BitMember)member;
-                           uint64 bits;
+                           uint64 bits = 0;
                            GetUInt64(memberExp, &bits);
                            bits &= bitMember.mask;
                            bits >>= bitMember.pos;
@@ -1232,7 +1247,8 @@ void DebugComputeExpression(Expression exp)
                      {
                         char * evaluation = null;
                         ExpressionType evalError = dummyExp;
-                        uint64 address;
+                        bool gotAddress = false;
+                        uint64 address = 0;
                         Expression prev = exp.prev, next = exp.next;
                         char format;
                         int size;
@@ -1268,13 +1284,15 @@ void DebugComputeExpression(Expression exp)
                            // VERIFY THIS: (trying to fix primitive.type)
                            // if(memberExp.type == constantExp)
                            if(memberExp.hasAddress && (_class.type != normalClass && _class.type != noHeadClass && _class.type != systemClass))
+                           {
                               address = memberExp.address;
+                              gotAddress = true;
+                           }
                            else if(memberExp.type == constantExp)
-                              GetUInt64(memberExp, &address);
+                              gotAddress = GetUInt64(memberExp, &address);
                            else
                            {
-                              address = 0;
-                              GetUInt64(memberExp, &address);
+                              gotAddress = GetUInt64(memberExp, &address);
                               //printf("Unhandled !!\n");
 
                               //printf("memberExp.hasAddress = %d\n", memberExp.hasAddress);
@@ -1284,7 +1302,9 @@ void DebugComputeExpression(Expression exp)
 
                            address += offset;
 
-                           if((dataType.kind == classType && dataType._class &&
+                           if(!gotAddress)
+                              exp.type = unknownErrorExp;
+                           else if((dataType.kind == classType && dataType._class &&
                                  (!dataType._class.registered || dataType._class.registered.type == normalClass || dataType._class.registered.type == noHeadClass || dataType._class.registered.type == systemClass)) ||
                               (dataType.kind != classType && dataType.kind != arrayType && dataType.kind != structType && dataType.kind != unionType))
                            {
@@ -1317,7 +1337,10 @@ void DebugComputeExpression(Expression exp)
                                  delete expNew;
                               }
                               else
+                              {
+                                 FreeExpContents(exp);
                                  exp.type = unknownErrorExp;
+                              }
                            }
                            else
                            {
@@ -1349,7 +1372,8 @@ void DebugComputeExpression(Expression exp)
                      {
                         char * evaluation = null;
                         ExpressionType evalError = dummyExp;
-                        uint64 address;
+                        uint64 address = 0;
+                        bool gotAddress = false;
                         Expression prev = exp.prev, next = exp.next;
                         char format;
                         int size = memberType.size;
@@ -1364,13 +1388,21 @@ void DebugComputeExpression(Expression exp)
                         format = GetGdbFormatChar(dataType);
 
                         if(memberExp.hasAddress)
+                        {
                            address = memberExp.address;
+                           gotAddress = true;
+                        }
                         else if(memberExp.type == constantExp)
-                           GetUInt64(memberExp, &address);
+                           gotAddress = GetUInt64(memberExp, &address);
 
                         address += offset;
 
-                        if((dataType.kind == classType && dataType._class &&
+                        if(!gotAddress)
+                        {
+                           FreeExpContents(exp);
+                           exp.type = unknownErrorExp;
+                        }
+                        else if((dataType.kind == classType && dataType._class &&
                               (!dataType._class.registered || dataType._class.registered.type == normalClass || dataType._class.registered.type == noHeadClass || dataType._class.registered.type == systemClass)) ||
                            (dataType.kind != classType && dataType.kind != arrayType && dataType.kind != structType && dataType.kind != unionType))
                         {
@@ -1402,7 +1434,10 @@ void DebugComputeExpression(Expression exp)
                               delete expNew;
                            }
                            else
+                           {
+                              FreeExpContents(exp);
                               exp.type = unknownErrorExp;
+                           }
                         }
                         else
                         {
@@ -1492,115 +1527,137 @@ void DebugComputeExpression(Expression exp)
                   case charType:
                      if(type.isSigned)
                      {
-                        char value;
-                        GetChar(exp.cast.exp, &value);
-                        FreeExpContents(exp);
-                        exp.constant = PrintChar(value);
-                        exp.type = constantExp;
-                        exp.isConstant = true;
+                        char value = 0;
+                        if(GetChar(exp.cast.exp, &value))
+                        {
+                           FreeExpContents(exp);
+                           exp.constant = PrintChar(value);
+                           exp.type = constantExp;
+                           exp.isConstant = true;
+                        }
                      }
                      else
                      {
-                        unsigned char value;
-                        GetUChar(exp.cast.exp, &value);
-                        FreeExpContents(exp);
-                        exp.constant = PrintUChar(value);
-                        exp.type = constantExp;
-                        exp.isConstant = true;
+                        unsigned char value = 0;
+                        if(GetUChar(exp.cast.exp, &value))
+                        {
+                           FreeExpContents(exp);
+                           exp.constant = PrintUChar(value);
+                           exp.type = constantExp;
+                           exp.isConstant = true;
+                        }
                      }
                      break;
                   case shortType:
                      if(type.isSigned)
                      {
-                        short value;
-                        GetShort(exp.cast.exp, &value);
-                        FreeExpContents(exp);
-                        exp.constant = PrintShort(value);
-                        exp.type = constantExp;
-                        exp.isConstant = true;
+                        short value = 0;
+                        if(GetShort(exp.cast.exp, &value))
+                        {
+                           FreeExpContents(exp);
+                           exp.constant = PrintShort(value);
+                           exp.type = constantExp;
+                           exp.isConstant = true;
+                        }
                      }
                      else
                      {
-                        unsigned short value;
-                        GetUShort(exp.cast.exp, &value);
-                        FreeExpContents(exp);
-                        exp.constant = PrintUShort(value);
-                        exp.type = constantExp;
-                        exp.isConstant = true;
+                        unsigned short value = 0;
+                        if(GetUShort(exp.cast.exp, &value))
+                        {
+                           FreeExpContents(exp);
+                           exp.constant = PrintUShort(value);
+                           exp.type = constantExp;
+                           exp.isConstant = true;
+                        }
                      }
                      break;
                   case intType:
                      if(type.isSigned)
                      {
-                        int value;
-                        GetInt(exp.cast.exp, &value);
-                        FreeExpContents(exp);
-                        exp.constant = PrintInt(value);
-                        exp.type = constantExp;
-                        exp.isConstant = true;
+                        int value = 0;
+                        if(GetInt(exp.cast.exp, &value))
+                        {
+                           FreeExpContents(exp);
+                           exp.constant = PrintInt(value);
+                           exp.type = constantExp;
+                           exp.isConstant = true;
+                        }
                      }
                      else
                      {
-                        unsigned int value;
-                        GetUInt(exp.cast.exp, &value);
-                        FreeExpContents(exp);
-                        exp.constant = PrintUInt(value);
-                        exp.type = constantExp;
-                        exp.isConstant = true;
+                        unsigned int value = 0;
+                        if(GetUInt(exp.cast.exp, &value))
+                        {
+                           FreeExpContents(exp);
+                           exp.constant = PrintUInt(value);
+                           exp.type = constantExp;
+                           exp.isConstant = true;
+                        }
                      }
                      break;
                   case int64Type:
                      if(type.isSigned)
                      {
-                        int64 value;
-                        GetInt64(exp.cast.exp, &value);
-                        FreeExpContents(exp);
-                        exp.constant = PrintInt64(value);
-                        exp.type = constantExp;
-                        exp.isConstant = true;
+                        int64 value = 0;
+                        if(GetInt64(exp.cast.exp, &value))
+                        {
+                           FreeExpContents(exp);
+                           exp.constant = PrintInt64(value);
+                           exp.type = constantExp;
+                           exp.isConstant = true;
+                        }
                      }
                      else
                      {
-                        uint64 value;
-                        GetUInt64(exp.cast.exp, &value);
-                        FreeExpContents(exp);
-                        exp.constant = PrintUInt64(value);
-                        exp.type = constantExp;
-                        exp.isConstant = true;
+                        uint64 value = 0;
+                        if(GetUInt64(exp.cast.exp, &value))
+                        {
+                           FreeExpContents(exp);
+                           exp.constant = PrintUInt64(value);
+                           exp.type = constantExp;
+                           exp.isConstant = true;
+                        }
                      }
                      break;
                   case pointerType:
                   case classType:
                   {
-                     uint64 value;
-                     GetUInt64(exp.cast.exp, &value);
-                     FreeExpContents(exp);
-                     if(type.kind == pointerType || type.kind == classType)
-                        exp.constant = PrintHexUInt64(value);
-                     else
-                        exp.constant = PrintUInt64(value);
-                     exp.type = constantExp;
-                     exp.isConstant = true;
+                     uint64 value = 0;
+                     if(GetUInt64(exp.cast.exp, &value))
+                     {
+                        FreeExpContents(exp);
+                        if(type.kind == pointerType || type.kind == classType)
+                           exp.constant = PrintHexUInt64(value);
+                        else
+                           exp.constant = PrintUInt64(value);
+                        exp.type = constantExp;
+                        exp.isConstant = true;
+                     }
                      break;
                   }
                   case floatType:
                   {
-                     float value;
-                     GetFloat(exp.cast.exp, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintFloat(value);
-                     exp.type = constantExp;
-                     exp.isConstant = true;
+                     float value = 0;
+                     if(GetFloat(exp.cast.exp, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintFloat(value);
+                        exp.type = constantExp;
+                        exp.isConstant = true;
+                     }
                      break;
                   }
                   case doubleType:
                   {
-                     double value;
-                     GetDouble(exp.cast.exp, &value);
-                     FreeExpContents(exp);
-                     exp.constant = PrintDouble(value);
-                     exp.type = constantExp;
-                     exp.isConstant = true;
+                     double value = 0;
+                     if(GetDouble(exp.cast.exp, &value))
+                     {
+                        FreeExpContents(exp);
+                        exp.constant = PrintDouble(value);
+                        exp.type = constantExp;
+                        exp.isConstant = true;
+                     }
                      break;
                   }
                }