You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plain ints are intended to have the natural width suggested by the architecture of the execution environment; the other signed integer types are provided to meet special needs.
I feel like this note is not doing much good at this point. Firstly, this sounds a lot like a Recommended practice paragraph, not like a note.
Besides that, it's not what implementers typically do, or should do. The "natural width" is the width of the general purpose register or the width of pointers; anything less will usually require zero- or sign-extension:
char* advance(char* p, int x) {
return p + x;
}
char* advance(char* p, longlong x) {
return p + x;
}
Clang emits:
advance(char*,int):movsxdrax,esiaddrax,rdiretadvance(char*, long long):learax,[rdi+rsi]ret
If implementers respected this note, int should be a 64-bit type on x86_64, which would make it "natural" and drop sign extensions. I don't believe this is useful or desirable; the general approach is to cap the int size at 32-bit, even if this makes it less natural and requires additional operations.
The text was updated successfully, but these errors were encountered:
[basic.fundamental] Note 1
I feel like this note is not doing much good at this point. Firstly, this sounds a lot like a Recommended practice paragraph, not like a note.
Besides that, it's not what implementers typically do, or should do. The "natural width" is the width of the general purpose register or the width of pointers; anything less will usually require zero- or sign-extension:
Clang emits:
If implementers respected this note,
int
should be a 64-bit type on x86_64, which would make it "natural" and drop sign extensions. I don't believe this is useful or desirable; the general approach is to cap theint
size at 32-bit, even if this makes it less natural and requires additional operations.The text was updated successfully, but these errors were encountered: