C++ Logo

std-discussion

Advanced search

Re: What is the reason of one rule of C++ ?

From: Brian Bi <bbi5291_at_[hidden]>
Date: Sat, 11 Nov 2023 22:17:20 -1000
On Sat, Nov 11, 2023, 8:45 PM Vadim Flyagin via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> Before getting to know about the existence of this mailing list, I asked
> the same question to Bjarne Stroustrup in a private e-mail. He replied that
> he is interested in this question too: “I thought it had to be a bug but
> MS, Clang, and GCC all do the same, so it's likely to be in the standard.
> Now I'm curious. It still looks like a bug to me. Thanks.”
> вс, 12 нояб. 2023 г. в 06:04, Vadim Flyagin <vadim.flyagin_at_[hidden]>:
>
>> Dear experts in the ISO C++ Standard!
>>
>> Konstantin Vladimirov, who is an informatics lecturer at Moscow Institute
>> of Physics and Technology (in particular, he teaches C++), initiated a
>> discussion recently about the following issue in his Telegram channel [1].
>>
>> He asked the following question and said that he does not know the
>> answer, nor have his subscribers found the answer yet. Maybe you could
>> answer this question? Below is my translation of this question from the
>> Russian:
>>
>> “Some strange kind of C++.
>>
>> Respected reader of my channel @MSerhiy has noticed a funny thing: there
>> are different rules of overloading for structures and for primitive types
>> in this example: [2].
>>
>> Quite soon, I grubbed up the answer in the standard.
>>
>> C++20, [expr.type] "If a prvalue initially has the type “cv T”, where T
>> is a cv-unqualified non-class, non-array type, the type of the expression
>> is adjusted to T prior to any further analysis"
>>
>> But I started pondering during the process for some reason. Just
>> hypothetically: why was this done so? This helps what things and when? I
>> have no ideas.
>>
>
https://cplusplus.github.io/CWG/issues/1026.html suggests that this rule
was inherited from C.


>> I propose to speculate concerning the source for this rule in this
>> thread.”
>>
>> Best wishes, Vadim.
>>
>> [1] https://t.me/cpp_lects_rus/136
>>
>> [2] https://godbolt.org/z/YT9bo7ore
>>
>> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>

Received on 2023-11-12 08:17:33