mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
core.builtins: Fix return value of likely/unlikely
For both GCC and LLVM, `__builtin_expect` and `llvm_expect` respectively return an integer, not a boolean. This triggers a compiler error as implicit narrow conversions are not allowed.
This commit is contained in:
parent
12d4f3e4d6
commit
126064282f
1 changed files with 2 additions and 2 deletions
|
@ -94,9 +94,9 @@ else version (DigitalMars)
|
|||
|
||||
/// Provide static branch and value hints for the LDC/GDC compilers.
|
||||
/// DMD ignores these hints.
|
||||
pragma(inline, true) bool likely()(bool b) { return expect(b, true); }
|
||||
pragma(inline, true) bool likely()(bool b) { return !!expect(b, true); }
|
||||
/// ditto
|
||||
pragma(inline, true) bool unlikely()(bool b) { return expect(b, false); }
|
||||
pragma(inline, true) bool unlikely()(bool b) { return !!expect(b, false); }
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue