Hacker News new | ask | show | jobs
by njohnson41 3958 days ago
You can convey some of that information to the compiler by using __builtin_unreachable(), e.g.:

  #define ASSUME(x) if(!(x))__builtin_unreachable()
This is compiler-specific, of course, and introduces undefined behavior if the assumption is violated. There's also no guarantee that the compiler will use the information well. But, it's almost guaranteed to not generate any extra code based on it.