[Issue 10574] "auto ref" fails to match when IFTI succeeds (strip to level const)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 11 11:04:36 PDT 2013


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



--- Comment #7 from Kenji Hara <k.hara.pg at gmail.com> 2013-07-11 11:04:34 PDT ---
(In reply to comment #6)
> For the record (without putting any words in Kenji's mouth), I think he was
> just stating what the compiler was *doing*, and why the code was rejected. I
> don't think he meant to say that the current behavior was correct.
> 
> Kenji, could you confirm that this is what you meant? That this is a correct
> "rejects-valid" ?

No, indeed I just talked about the current compiler's work, but I'm sure that
current behavior is correct.

The main point is what "auto ref" is doing - it's ref-ness deduction.
If given argument is an lvalue, auto ref parameter would become ref. If it's an
rvalue, would become non-ref. Nothing else is done.
Type deduction and ref-ness deduction are completely orthogonal. It means that
the combination of each deduction results might finally reject given argument.
It's exactly what happened in the OP code.

So I can say it's expected behavior.

I believe that one language feature (in here "auto ref") should do just one
thing correctly. Orthogonality between each features could reduce language's
"special case", and combining them would bring abundant usage. For example,
when you use "auto ref", the ref-ness deduction reliably avoids
copy-construction of given argument.

A brief conclusion is: "auto ref" is not a magic parameter.

-- 
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