Bug 12026 – One missing statement is not reachable error message

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-29T08:23:33Z
Last change time
2022-12-02T16:00:26Z
Keywords
diagnostic
Assigned to
No Owner
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-01-29T08:23:33Z
dmd 2.065beta compiles this with no errors nor warnings: void foo(ref int i) { if (i != 10 || i != 12) return; i++; } void main() {} But I think that code should give (I consider this an enhancement request): test.d(4): Warning: statement is not reachable Because the (i != 10 || i != 12) condition is always true (also because foo is not a template function).
Comment #1 by razvan.nitu1305 — 2022-12-02T16:00:26Z
That would require to do extra analysis on the condition which is quite complicated in the general case.