[Issue 10147] Make -w identical to -wi and deprecate it

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 23 19:27:41 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10147



--- Comment #2 from Jonathan M Davis <jmdavisProg at gmx.com> 2013-05-23 19:27:40 PDT ---
> Can you please be more specific, maybe with example code? I have no knowledge
> of any of this.

Okay. Let's say that you have a function like

auto foo(T)(T t)
{
    switch(t.val)
    {
        case 1:
            writeln("warnings");
        case 2:
            writeln("become");
        case 3:
            writeln("errors");
        default:
            break;
    }

    return t.ret;
}

Without -w, this code will compile just fine (assuming that T has a member
called val which works with a switch statement as well as a member called ret).
But with -w, it won't compile thanks to the fact that it uses implicit
fallthrough. Now, say you have a function like

auto bar(T)(T t)
    if(is(typeof(foo(T.init))))
{
    ...
}

The template constraint passes if the argument compiles with foo and fails if
it doesn't. So, without -w, if you have the type

struct S
{
    int val;
    int ret;
}

and you pass it to bar, the code will compile. But if you compile with -w, it
won't, because foo no longer compiles thanks to implicit fallthrough becoming
an error.

_Anything_ that tests whether code compiles potentially breaks thanks to -w.
How big a problem this is in practice, I don't know, but -w can change the
semantics of code, meaning that whether you compile with -w or not effectively
creates two different languages. Normally, we reject any suggestions that
involve flags like this. -w really makes no sense.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list