Closed wallabra closed 2 months ago
__builtin_unreachable
is not part of the C standard and not portable (as indicated by the double-underscore). MSVC offers __assume(0)
as an alternative, but there also needs to be an alternative implementation for any other compilers supporting neither of those.
I don't know of a portable and idiomatic alternative, but there probably is one.
In the meanwhile, it might be best to use the preprocessor and using defines within ifdef clauses.
Issue fixed in main
(Elevated from https://github.com/noisetorch/rnnoise/pull/1)
This style of inducing the compiler to produce a x86 trap isn't used anymore, because it's opaque in its meaning, and has been replaced with internals like
__builtin_trap
or__builtin_unreachable
. Here I use the latter because I think it conveys the semantics better, to both the compiler and the reader.The main reason of this pull request, of course, is that, at least with Clang (but possibly also GCC), the lines of code in question were producing fatal errors with the default build configuration, which included
-Werror
. A workaround is to add-Wno-error=null-dereference
, but why sweep the issues under the rug and let them stack for our future selves when we can solve them right away? Those edits were pretty simple to make :)