[Issue 22646] New: [REG2.099] CT bounds checking ignores short circuit evaluation
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 3 17:56:17 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22646
Issue ID: 22646
Summary: [REG2.099] CT bounds checking ignores short circuit
evaluation
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dlang-bugzilla at thecybershadow.net
///////////////////////// test.d /////////////////////////
static template Bug(string name)
{
enum bool ok = name.length < 3 || name[0..3] != "pad";
}
pragma(msg, Bug!"x".ok);
pragma(msg, Bug!"foo".ok);
pragma(msg, Bug!"pad".ok);
pragma(msg, Bug!"pad123".ok);
//////////////////////////////////////////////////////////
This now fails with:
test.d(3): Error: in slice `"x"[0 .. 3]`, upper bound is greater than array
length `1`
test.d(6): Error: template instance `test.Bug!"x"` error instantiating
test.d(6): while evaluating `pragma(msg, Bug!"x".ok)`
Introduced in https://github.com/dlang/dmd/pull/13169
--
More information about the Digitalmars-d-bugs
mailing list