[Issue 24520] New: [REG] C-style casts are now accepted (sometimes)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Apr 24 09:19:20 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24520
Issue ID: 24520
Summary: [REG] C-style casts are now accepted (sometimes)
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: aliloko at gmail.com
# How to repro
Please consider the following file:
void main(string[] args)
{
// 1st change: the ending ';' starts being
// accepted in LDC 1.35, before was an error
// If that changed silently, then new code breaks in
// older compilers, creating disruption.
enum { A = 5};
// 2nd change:
// This C-style cast starts being accepted in LDC 1.35+
long c;
int i = (int) (c % 8);
// Note that this cast is always rejected whatever the
// compiler version
//int j = (int)4;
}
Some parses that were invalid in LDC 1.34 (DMDFE v2.104.2) became accepted in
LDC 1.35 (DMDFE v2.105.2)
If new compilers accept invalid code without complaints, it _might_ be
intentional and a language change, but please hear me, this is a problem of
quality of life in practice for the ecosystem, because then people build with
older compiler the code that was produced with new compilers, and it simply
breaks there for a lot of people that depend on it.
And it's documented nowhere! It's also silent, so would bypass any Edition I
guess and break code regardless.
https://dlang.org/changelog/2.105.0.html
--
More information about the Digitalmars-d-bugs
mailing list