Created
February 11, 2017 20:24
-
-
Save vittorioromeo/197b9780bf153cdbf34fc4c745858f29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define assume(cond) do { if (!(cond)) __builtin_unreachable(); } while (0) | |
| int func(int x){ | |
| assume(x >=0 && x <= 10); | |
| if ( x > 11 ){ | |
| return 2; | |
| }else{ | |
| return 17; | |
| } | |
| } | |
| #undef assume | |
| #define assume(cond) do { if (!(cond)) detail::unreachable(); } while (0) | |
| namespace detail { | |
| [[noreturn]] void unreachable(){} | |
| } | |
| int func2(int x){ | |
| assume(x >=0 && x <= 10); | |
| if ( x > 11 ){ | |
| return 2; | |
| }else{ | |
| return 17; | |
| } | |
| } | |
| #undef assume | |
| #define assume(cond) __builtin_assume(cond) | |
| int func3(int x){ | |
| assume(x >=0 && x <= 10); | |
| if ( x > 11 ){ | |
| return 2; | |
| }else{ | |
| return 17; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment