RFR: 8257420: Zero VM build broken with clang after JDK-8256726 due to strlen() is not a constexpr [v3]

David Holmes david.holmes at oracle.com
Tue Dec 1 02:34:17 UTC 2020


On 1/12/2020 3:11 am, Thomas Stuefe wrote:
> On Mon, 30 Nov 2020 15:24:12 GMT, Jie Fu <jiefu at openjdk.org> wrote:
> 
>>> Hi all,
>>>
>>> The newly added STATIC_ASSERT [1] breaks the build of Zero VM with clang.
>>> It complains that 'non-type template argument is not a constant expression' since strlen() [2] is not a constexpr.
>>>
>>> Any comments?
>>>
>>> Thanks.
>>> Best regards,
>>> Jie
>>>
>>> [1] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp#L1374
>>> [2] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/flags/jvmFlagLookup.hpp#L42
>>
>> Jie Fu has updated the pull request incrementally with one additional commit since the last revision:
>>
>>    Inline add_len
> 
> Looks fine.
> 
> I guess another solution would have been
> 
> #define MSGFMT "Index %d out of bounds for length %d"
> #define add_len sizeof(MSGFMT)

I didn't realize that would work. I thought the use of the string 
literal would decay into a "const char * const" and thus sizeof would 
give the size of the pointer.

> ..
> char message[2 * jintAsStringSize + add_len];

Except you subtract four for the two %d ocurrences.

David
-----

> ..
> jio_snprintf(message, sizeof(message), MSGFMT, \
> ...
> to spare you the character counting
> 
> -------------
> 
> Marked as reviewed by stuefe (Reviewer).
> 
> PR: https://git.openjdk.java.net/jdk/pull/1518
> 


More information about the hotspot-runtime-dev mailing list