Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Well, it wouldn't reach into functions. It would mainly just change the + and - operators within its scope to return a larger type. So instead of

    int32_t plus(int32_t left, int32_t right);
the plus operator would be equivalent to

    int64_t plus(int32_t left, int32_t right);
So basically

    int32_t a = 2000000000;
    int32_t b = 2000000000;
    int64_t c = __no_overflow(a+b);
    // now c is 4000000000;
I don't claim the idea to be flawless or completely thought out, but I believe something like that could be one of the more useful C language extensions.

Oh, and thanks for the link!



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: