Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Don’t assume that safety comes for free: a Swift case study. Parent comment
The danger is
signed int x; cin>>x; if(x+1<x){return OVERFLOW;}
will, in modern optimizing compilers, never return OVERFLOW
There were quite a few security holes introduced by the compiler with that.
-----
The only problem is to make a standard, one has to define that MAX_INT+1 = 0 or something. Then, whenever one does
signed int x;
cin>> x;
signed int y = x+1;
really turns into
signed int = 0;
if ( x < MAX_INT)
y= x+1
else
y = 1;
There are no comments on this comment yet.
The danger is
signed int x; cin>>x; if(x+1<x){return OVERFLOW;}
will, in modern optimizing compilers, never return OVERFLOW
There were quite a few security holes introduced by the compiler with that.
-----
The only problem is to make a standard, one has to define that MAX_INT+1 = 0 or something. Then, whenever one does
signed int x;
cin>> x;
signed int y = x+1;
really turns into
signed int = 0;
if ( x < MAX_INT)
y= x+1
else
y = 1;