arocc icon indicating copy to clipboard operation
arocc copied to clipboard

Support statically-known indexing into string literals

Open ehaas opened this issue 11 months ago • 0 comments

This works in clang but not GCC:

_Static_assert("hello"[0] == 'h', "");
_Static_assert(("hello" + 1)[0] == 'e', "");
_Static_assert((&("hello"[1]))[0] == 'e', "");
_Static_assert((("hello" + 1) - 1)[0] == 'h', "");

ehaas avatar Jan 07 '25 05:01 ehaas