It's possible there's a smaller repro, but I found two surprising things at once, so I stopped before maybe mis-reducing one of them
Repro zig test .zig:
Analyzing offset1 triggers a compiler crash (no output, Windows exit code -1073741819).
Commenting out offset1, analyzing offset2 (initialized from the same code with the method call inlined) instead results the following compile error:
.zig:26:36: error: unable to evaluate comptime expression
break :offset2 element_pointer - base_pointer;
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
.zig:26:36: note: operation is runtime due to this operand
This doesn't really make sense to me, because it refers to a statement inside a comptime block, where all values should be comptime-known.
The compiler complains if I add an explicit unary comptime operator anywhere within the block, which prevents me from further investigation.
The note "due to this operand" also doesn't point to any singular operand, which seems wrong (gives me nothing to act upon).
Expected Behavior
In my eyes the code initializing offset1, offset2, and offset3 should be equivalent and seems correct, so should be accepted and result in the same value.
Zig Version
0.14.0-dev.1579+f3445f8f6
Steps to Reproduce and Observed Behavior
It's possible there's a smaller repro, but I found two surprising things at once, so I stopped before maybe mis-reducing one of them Repro
zig test .zig
:Analyzing
offset1
triggers a compiler crash (no output, Windows exit code -1073741819).Commenting out
offset1
, analyzingoffset2
(initialized from the same code with the method call inlined) instead results the following compile error:This doesn't really make sense to me, because it refers to a statement inside a
comptime
block, where all values should becomptime
-known. The compiler complains if I add an explicit unarycomptime
operator anywhere within the block, which prevents me from further investigation. The note "due to this operand" also doesn't point to any singular operand, which seems wrong (gives me nothing to act upon).Expected Behavior
In my eyes the code initializing
offset1
,offset2
, andoffset3
should be equivalent and seems correct, so should be accepted and result in the same value.