Bug 24112 – binary expressions with noreturn vars produce inconsistent results

Status
REOPENED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-08-26T20:20:01Z
Last change time
2024-12-13T19:30:37Z
Keywords
pull, rejects-valid, wrong-code
Assigned to
No Owner
Creator
elpenguino+D
Moved to GitHub: dmd#18184 →

Comments

Comment #0 by elpenguino+D — 2023-08-26T20:20:01Z
``` noreturn foo; int a = foo / 1; int b = foo + 1; int c = foo - 1; int d = foo * 1; int e = foo % 1; int f = foo ^^ 1; int g = foo & 1; int h = foo | 1; int i = foo ^ 1; int j = foo << 1; int k = foo >> 1; int l = foo >>> 1; ``` As of DMD 2.105.0, none of these statements produce the expected runtime errors. noreturn vars appear to be treated as integers with the value 0, except in the last three statements, which result in a compile error instead.
Comment #1 by dlang-bot — 2023-08-30T15:16:04Z
@ntrel created dlang/dmd pull request #15564 "Fix Issue 24112 - binary expressions with noreturn vars produce incon…" fixing this issue: - Fix Issue 24112 - binary expressions with noreturn vars produce inconsistent results https://github.com/dlang/dmd/pull/15564
Comment #2 by nick — 2023-08-30T15:19:27Z
> except in the last three statements, which result in a compile error instead. I think that's correct as the spec says: > The operands must be integral types https://dlang.org/spec/expression.html#shift_expressions
Comment #3 by elpenguino+D — 2023-08-30T15:28:41Z
it's true that noreturn isn't an integral type, but it can implicitly convert to integral types. other instances of implicit conversion are allowed (structs with integer alias this, for example), so I think noreturn should be "allowed" as well, for consistency
Comment #4 by dlang-bot — 2023-09-07T10:56:50Z
dlang/dmd pull request #15564 "Fix Issue 24112 - binary expressions with noreturn vars produce incon…" was merged into master: - c5f9ca5bd2952b8f0667ab94133477e83596cdb9 by Nick Treleaven: Fix Issue 24112 - binary expressions with noreturn vars produce inconsistent results https://github.com/dlang/dmd/pull/15564
Comment #5 by b2.temp — 2023-09-07T13:38:32Z
The fixed that was merged breaks the one for https://issues.dlang.org/show_bug.cgi?id=24117
Comment #6 by dlang-bot — 2023-09-07T15:33:24Z
dlang/dmd pull request #15584 "Revert "Fix Issue 24112 - binary expressions with noreturn vars produ…" was merged into master: - a90c6d25063b2f5a4e17c165acc63a2800ac68ac by Basile Burg: Revert "Fix Issue 24112 - binary expressions with noreturn vars produce inconsistent results (#15564)" This reverts commit 1a9a19f8b384a4c9f6d27dcd04f83bf8dd1546cf. This breaks the test suite (fail_compilation/noreturn_expr.d). https://github.com/dlang/dmd/pull/15584
Comment #7 by robert.schadek — 2024-12-13T19:30:37Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18184 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB