comparison dmd/expression.c @ 1120:0d38fa5a0b46

Another "pointers are 32 bits" issue in the frontend. long/ulong constants cast to pointers were truncated to 32-bit values. Closes #234.
author Frits van Bommel <fvbommel wxs.nl>
date Sun, 15 Mar 2009 15:58:38 +0100
parents b30fe7e1dbb9
children e7f0c2b48047
comparison
equal deleted inserted replaced
1119:2cd6199488f6 1120:0d38fa5a0b46
1346 case Tuns8: value = (d_uns8) value; break; 1346 case Tuns8: value = (d_uns8) value; break;
1347 case Tint16: value = (d_int16) value; break; 1347 case Tint16: value = (d_int16) value; break;
1348 case Twchar: 1348 case Twchar:
1349 case Tuns16: value = (d_uns16) value; break; 1349 case Tuns16: value = (d_uns16) value; break;
1350 case Tint32: value = (d_int32) value; break; 1350 case Tint32: value = (d_int32) value; break;
1351 case Tpointer:
1352 case Tdchar: 1351 case Tdchar:
1353 case Tuns32: value = (d_uns32) value; break; 1352 case Tuns32: value = (d_uns32) value; break;
1354 case Tint64: value = (d_int64) value; break; 1353 case Tint64: value = (d_int64) value; break;
1355 case Tuns64: value = (d_uns64) value; break; 1354 case Tuns64: value = (d_uns64) value; break;
1355 case Tpointer:
1356 // FIXME: Other pointer widths than 32 and 64?
1357 if (PTRSIZE == 4)
1358 value = (d_uns32) value;
1359 else
1360 value = (d_uns64) value;
1361 break;
1356 1362
1357 case Tenum: 1363 case Tenum:
1358 { 1364 {
1359 TypeEnum *te = (TypeEnum *)t; 1365 TypeEnum *te = (TypeEnum *)t;
1360 t = te->sym->memtype; 1366 t = te->sym->memtype;
1510 case Tint64: 1516 case Tint64:
1511 buf->printf("%jdL", v); 1517 buf->printf("%jdL", v);
1512 break; 1518 break;
1513 1519
1514 case Tuns64: 1520 case Tuns64:
1521 L4:
1515 buf->printf("%juLU", v); 1522 buf->printf("%juLU", v);
1516 break; 1523 break;
1517 1524
1518 case Tbit: 1525 case Tbit:
1519 case Tbool: 1526 case Tbool:
1522 1529
1523 case Tpointer: 1530 case Tpointer:
1524 buf->writestring("cast("); 1531 buf->writestring("cast(");
1525 buf->writestring(t->toChars()); 1532 buf->writestring(t->toChars());
1526 buf->writeByte(')'); 1533 buf->writeByte(')');
1527 goto L3; 1534 // FIXME: Other pointer widths than 32 and 64?
1535 if (PTRSIZE == 4)
1536 goto L3;
1537 else
1538 goto L4;
1528 1539
1529 default: 1540 default:
1530 /* This can happen if errors, such as 1541 /* This can happen if errors, such as
1531 * the type is painted on like in fromConstInitializer(). 1542 * the type is painted on like in fromConstInitializer().
1532 */ 1543 */