Re: unclear error message: operator->() must be a non-static member function

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

 



On Thu, 31 Oct 2024 at 15:24, Fiodar <fedor_qd@xxxxxxx> wrote:
>
>
> It doesn’t say why.
>
> Compare two GCC reports:
> error: must be a non-static member function
> and
> warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
>
> More clear error message as for me may be:
> error: ISO C++ does not allow non-static member function 'R* operator->(const R&)'

GCC only uses the "ISO C++ does not allow ..." form for rules that are
modified by GCC extensions. So for -Wregister it's telling you that
the keyword is allowed by GCC, but is not allowed by ISO C++.

For the first case, it's never allowed. It's not valid in ISO C++ and
it's not valid in GNU C++. So I disagree with your suggestion. It
would be confusing and inconsistent to say "ISO C++ does not allow
..." for something that is never allowed by any form of C++. It's not
allowed by ISO C++, or GNU C++, or traditional 1990s C++ before there
was a standard.

> Yes, I already know why that operator must be that.  https://en.cppreference.com/w/cpp/language/operators

If the compiler says something is not allowed, you should assume it's
because the language rules don't allow it. That's how compilers work.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux