On Mon, 30 Mar 2026 16:59:53 GMT, Quan Anh Mai <[email protected]> wrote:

>> Ooops, I think my IDE somehow tricked me into this. But the interesting 
>> thing is that it does trigger without the fix. Not sure why though.
>
> I assume it is because `assert` is a macro (the thing you often call 
> `assert(cond, msg, ...)`) that is defined if `ASSERT` is defined. So, `#ifdef 
> ASSERT` is the same as `#ifdef assert` :)

It's not the same, it's always on: even in product, `assert` is defined, just 
expand to nothing (I don't think it would compile otherwise):

#ifndef ASSERT
// [...]
#define vmassert(p, ...)
#else
// [...]
#define vmassert(p, ...) vmassert_with_file_and_line(p, __FILE__, __LINE__, 
__VA_ARGS__)
#endif
[...]
#define assert(p, ...) vmassert(p, __VA_ARGS__)


So `#ifdef assert` (in places where debug.hpp is included) is like `#if 1`.

But the `assert` "call" in it is nop in product.

-------------

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2256#discussion_r3013957786

Reply via email to