lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Unexpected clang error message


From: Greg Chicares
Subject: Re: [lmi] Unexpected clang error message
Date: Wed, 3 Aug 2022 14:39:26 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0

On 8/3/22 12:23, Vadim Zeitlin wrote:
> On Tue, 2 Aug 2022 20:19:33 +0000 Greg Chicares <gchicares@sbcglobal.net> 
> wrote:
> 
> GC> I expect a particular clang error message, but get a different one,
> GC> when I compile the code below in these two different ways, with
> GC> macro "NONEMPTY" variously defined or undefined:
> GC> 
> GC> $clang++ -DNONEMPTY -fsyntax-only -Wall -std=c++20 eraseme.cpp 2>&1 |grep 
> 'error:'
> GC> eraseme.cpp:28:7: error: call to constructor of 'X' is ambiguous
> 
>  For me, this is indeed expected because you define a ctor, and even
> multiple ctors, and the compiler can't choose between them.

Yes: exactly as expected, and indeed also as intended.

> GC> $clang++ -UNONEMPTY -fsyntax-only -Wall -std=c++20 eraseme.cpp 2>&1 |grep 
> 'error:'
> GC> eraseme.cpp:28:10: error: excess elements in struct initializer
> 
>  For me, this is expected too because you don't define any ctors and hence
> the struct is an aggregate

Oh. Thanks, that explains it.

I was thinking that this error message looked like an initializer-list
had come into play, but I dismissed that idea because I was focusing
on the question of whether both cases have the same move and copy ctors.

I woke up this morning thinking I had accidentally discovered a way to
distinguish the all-SMFs-explicitly-defaulted case from the no-SMF-written
case. That seemed curious, though not necessarily useful. Now I see that
what I "discovered" is only std::is_aggregate.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]