C++ Logo

std-discussion

Advanced search

Re: Function overload resolution

From: Christof Meerwald <cmeerw_at_[hidden]>
Date: Mon, 27 Sep 2021 20:12:42 +0200
On Mon, Sep 27, 2021 at 07:22:37PM +0300, Vladimir Grigoriev via Std-Discussion wrote:
> In my opinion there is some inconsistence in the function overload resolution when a function parameter has a referenced array type.
>  
> Let assume that we have two functions
>  
> void f( const ( &a )[] );
>  
> and
>  
> void f( const ( &a )[2] );
>  
> If to write
>  
> f( { 1, 2 } );
>  
> then the second function will be selected.
>  
> However if to write
>  
> int a[2];
>  
> and then
>  
> f( a );
>  
> then the compiler will issue an error relative to an ambiguity.

Which compiler? MSVC? Maybe a compiler bug?

gcc accepts this: https://gcc.godbolt.org/z/5qq4G6hcW

This is discussed in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0388r4.html .


Christof

-- 
https://cmeerw.org                             sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org                   xmpp:cmeerw at cmeerw.org

Received on 2021-09-27 13:12:50