digitalmars.D.learn - what happened to the reachability diag ?
- Basile B. (37/37) Dec 10 I've been away of D since a while but I'm surprised to see DMD
- Richard (Rikki) Andrew Cattermole (3/3) Dec 10 It was removed.
- Basile B. (5/8) Dec 10 at least `main()` is a problem. Obviously the examples are catchy
- Kapendev (5/14) Dec 10 It’s easy to use `static if`s or `mixin`s in a way that produce
- Basile B. (4/20) Dec 10 no template, no metaprog, no mixin, involved here. You're going
- monkyyy (3/16) Dec 10 your in an extreme minority here im pretty sure, 85%ish was in
- Kapendev (4/8) Dec 10 I don't know who "Richard" is.
- Richard (Rikki) Andrew Cattermole (2/10) Dec 10 Me :P
- Richard (Rikki) Andrew Cattermole (29/40) Dec 10 If that is instantiated with an int for the type, it errored.
I've been away of D since a while but I'm surprised to see DMD
accepting this input without any **warning**s
```d
module runnable;
void main() nothrow // no landing pad
{
enum E {e0}
E e;
final switch (e)
{
case E.e0: goto case E.e0;
}
return; // statement not reachable
}
void other() nothrow // no landing pad
{
enum E {e0}
E e;
final switch (e)
{
case E.e0: goto case E.e0;
}
int a; // declaration not reachable
}
int shoudlebeLike()
{
assert(0) ;
while (true)
{
other();
}
assert(0);
other();
return 0;
}
```
(tried with -w -wi, etc).
Dec 10
It was removed. Its dead code, not hurting anyone, and just being plain annoying with templates.
Dec 10
On Wednesday, 10 December 2025 at 15:32:39 UTC, Richard (Rikki) Andrew Cattermole wrote:It was removed. Its dead code, not hurting anyone, and just being plain annoying with templates.at least `main()` is a problem. Obviously the examples are catchy on purpose. Prepare a console and killall. Seriously I don't get your argument.
Dec 10
On Wednesday, 10 December 2025 at 15:54:15 UTC, Basile B. wrote:On Wednesday, 10 December 2025 at 15:32:39 UTC, Richard (Rikki) Andrew Cattermole wrote:It’s easy to use `static if`s or `mixin`s in a way that produce something functionally equivalent to what you wrote. The way things work currently makes it easier to do metaprogramming. In practice this is not an issue even for "normal" code.It was removed. Its dead code, not hurting anyone, and just being plain annoying with templates.at least `main()` is a problem. Obviously the examples are catchy on purpose. Prepare a console and killall. Seriously I don't get your argument.
Dec 10
On Wednesday, 10 December 2025 at 16:07:13 UTC, Kapendev wrote:On Wednesday, 10 December 2025 at 15:54:15 UTC, Basile B. wrote:no template, no metaprog, no mixin, involved here. You're going into Richard answer. Point is just "very simply" that you should get a warning here.On Wednesday, 10 December 2025 at 15:32:39 UTC, Richard (Rikki) Andrew Cattermole wrote:It’s easy to use `static if`s or `mixin`s in a way that produce something functionally equivalent to what you wrote. The way things work currently makes it easier to do metaprogramming. In practice this is not an issue even for "normal" code.It was removed. Its dead code, not hurting anyone, and just being plain annoying with templates.at least `main()` is a problem. Obviously the examples are catchy on purpose. Prepare a console and killall. Seriously I don't get your argument.
Dec 10
On Wednesday, 10 December 2025 at 17:53:18 UTC, Basile B. wrote:On Wednesday, 10 December 2025 at 16:07:13 UTC, Kapendev wrote:your in an extreme minority here im pretty sure, 85%ish was in favorOn Wednesday, 10 December 2025 at 15:54:15 UTC, Basile B. wrote:no template, no metaprog, no mixin, involved here. You're going into Richard answer. Point is just "very simply" that you should get a warning here.[...]It’s easy to use `static if`s or `mixin`s in a way that produce something functionally equivalent to what you wrote. The way things work currently makes it easier to do metaprogramming. In practice this is not an issue even for "normal" code.
Dec 10
On Wednesday, 10 December 2025 at 17:53:18 UTC, Basile B. wrote:no template, no metaprog, no mixin, involved here. You're going into Richard answer. Point is just "very simply" that you should get a warning here.I don't know who "Richard" is. Warnings are helpful when they actually prevent something serious. As I already said:In practice this is not an issue even for "normal" code.
Dec 10
On 11/12/2025 8:04 AM, Kapendev wrote:On Wednesday, 10 December 2025 at 17:53:18 UTC, Basile B. wrote:Me :Pno template, no metaprog, no mixin, involved here. You're going into Richard answer. Point is just "very simply" that you should get a warning here.I don't know who "Richard" is. Warnings are helpful when they actually prevent something serious. As I already said:
Dec 10
On 11/12/2025 4:54 AM, Basile B. wrote:On Wednesday, 10 December 2025 at 15:32:39 UTC, Richard (Rikki) Andrew Cattermole wrote:If that is instantiated with an int for the type, it errored. This happened enough that it was on peoples hit list as a false positive nearing 100% of the time they got it. ```d void func(T)() { static if (is(T = int)) { assert(0); } writeln("hello"); } ``` ----------------------------- In your example, infinite loops can be valid and desirable things. If you want to catch that it should be done with a static analyzer, not as part of the compiler. It will get optimized to: ``` _Dmain: .Lfunc_begin0: .cfi_startproc .p2align 4, 0x90 .LBB0_1: jmp .LBB0_1 .Lfunc_end0: .size _Dmain, .Lfunc_end0-_Dmain .cfi_endproc ``` Compilers keep these loops for a reason.It was removed. Its dead code, not hurting anyone, and just being plain annoying with templates.at least `main()` is a problem. Obviously the examples are catchy on purpose. Prepare a console and killall. Seriously I don't get your argument.
Dec 10









monkyyy <crazymonkyyy gmail.com> 