History

x86-64: Cast from 64bit pointer to long long must not generate movslq.

Shinichiro Hamaji committed 17 years ago

Commit be43c8e1 parent a9c78d02 files · +11 −1Browse files

Unified · Split

2 files
  1. tcc.c +1 −1
  2. tcctest.c +10 −0
tcc.c+1−1
@@ -6228,7 +6228,7 @@ static void gen_cast(CType *type) · 6227 unmodified lines
62286228 vpop();
62296229 #else
62306230 int r = gv(RC_INT);
6231− if (sbt != (VT_INT | VT_UNSIGNED)) {
6231+ if (sbt != (VT_INT | VT_UNSIGNED) && sbt != VT_PTR) {
62326232 /* x86_64 specific: movslq */
62336233 o(0x6348);
62346234 o(0xc0 + (REG_VALUE(r) << 3) + REG_VALUE(r));
tcctest.c+10−0
@@ -1109,6 +1109,8 @@ void cast_test() · 1108 unmodified lines
11091109 char tab[10];
11101110 unsigned b,d;
11111111 short s;
1112+ char *p = NULL;
1113+ p -= 0x700000000042;
11121114
11131115 printf("cast_test:\n");
11141116 a = 0xfffff;
@@ -1150,6 +1152,14 @@ void cast_test() · 35 unmodified lines
11501152 printf("sizeof(+(char)'a') = %d\n", sizeof(+(char)'a'));
11511153 printf("sizeof(-(char)'a') = %d\n", sizeof(-(char)'a'));
11521154 printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a'));
1155+
1156+ /* from pointer to integer types */
1157+ printf("%d %d %d %d %d %d %ld %ld %lld %lld\n",
1158+ (char)p, (unsigned char)p,
1159+ (short)p, (unsigned short)p,
1160+ (int)p, (unsigned int)p,
1161+ (long)p, (unsigned long)p,
1162+ (long long)p, (unsigned long long)p);
11531163 }
11541164
11551165 /* initializers tests */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t