Date: Tue, 22 Jun 2021 17:48:16 +0000
This can seem like a silly bug report only because the code sample I am using is a minimal reproduction and not real life code.
In my real life code, there was an alias in one of the included headers which accidently happened to have the same name as the deduction guide parameter. The compiler throws a bunch of error messages which are all unrelated to the issue except for one message which says "illegal use of this type as an expression." When you have no clue what is going on, you can't tell which one of the different error messages is the important one, and it can take you hours of debugging until you discover the issue, and you will feel bad at the end when you find out that it was not an error by you but a compiler bug.
________________________________
From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Sent: Tuesday, June 22, 2021 12:30 PM
To: std-discussion_at_[hidden] <std-discussion_at_[hidden]>
Cc: Hani Deek <Hani_deek_at_[hidden]>
Subject: Re: [std-discussion] MSVC issue with name lookup in user-defined deduction guide
On Tue, 22 Jun 2021 at 20:23, Hani Deek via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> I filed a bug report to MSVC about the code sample in this link https://godbolt.org/z/1nnxWhK4f
>
> It compiles without problems with GCC and Clang, but does not compile with MSVC.
>
> The link to the bug report that I submitted is https://developercommunity.visualstudio.com/t/Incorrect-name-lookup-in-user-defined-de/1456401.
>
> The answer that I received from Microsoft to the bug report is unclear, but apparently they say that their compiler is correct to refuse the code sample. It will compile only if you use the /permissive switch, which allows non-standard-conforming code to compile.
>
> I generally have low trust in what the MSVC people say on such matters, because in the past they dismissed some bug reports that I submitted without real basis. Apparently they just try to reduce their workload by arbitrarily dismissing some bug reports which they deem unimportant.
>
> The latest C++ standard says under [6.4.4] "If [a parameter-declaration-clause] P is associated with a deduction-guide, its scope extends to the end of the deduction-guide." Therefore, I believe the code should compile without the /permissive switch, isn't that correct?
Seems correct to me. I personally would, however, write the code so
that the question of how the naming clash is resolved never
arises, by not naming the parameter of the guide the same as a type or
alias in the surrounding scope. And when that is done,
the code is accepted by all compilers.
In my real life code, there was an alias in one of the included headers which accidently happened to have the same name as the deduction guide parameter. The compiler throws a bunch of error messages which are all unrelated to the issue except for one message which says "illegal use of this type as an expression." When you have no clue what is going on, you can't tell which one of the different error messages is the important one, and it can take you hours of debugging until you discover the issue, and you will feel bad at the end when you find out that it was not an error by you but a compiler bug.
________________________________
From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Sent: Tuesday, June 22, 2021 12:30 PM
To: std-discussion_at_[hidden] <std-discussion_at_[hidden]>
Cc: Hani Deek <Hani_deek_at_[hidden]>
Subject: Re: [std-discussion] MSVC issue with name lookup in user-defined deduction guide
On Tue, 22 Jun 2021 at 20:23, Hani Deek via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> I filed a bug report to MSVC about the code sample in this link https://godbolt.org/z/1nnxWhK4f
>
> It compiles without problems with GCC and Clang, but does not compile with MSVC.
>
> The link to the bug report that I submitted is https://developercommunity.visualstudio.com/t/Incorrect-name-lookup-in-user-defined-de/1456401.
>
> The answer that I received from Microsoft to the bug report is unclear, but apparently they say that their compiler is correct to refuse the code sample. It will compile only if you use the /permissive switch, which allows non-standard-conforming code to compile.
>
> I generally have low trust in what the MSVC people say on such matters, because in the past they dismissed some bug reports that I submitted without real basis. Apparently they just try to reduce their workload by arbitrarily dismissing some bug reports which they deem unimportant.
>
> The latest C++ standard says under [6.4.4] "If [a parameter-declaration-clause] P is associated with a deduction-guide, its scope extends to the end of the deduction-guide." Therefore, I believe the code should compile without the /permissive switch, isn't that correct?
Seems correct to me. I personally would, however, write the code so
that the question of how the naming clash is resolved never
arises, by not naming the parameter of the guide the same as a type or
alias in the surrounding scope. And when that is done,
the code is accepted by all compilers.
Received on 2021-06-22 12:48:23