public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/104418] [C++14+] Error inheriting base class constructors by using-declaration
Date: Tue, 08 Feb 2022 02:51:22 +0000	[thread overview]
Message-ID: <bug-104418-4-7RCKBFb7sV@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104418-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104418

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
            Summary|Error inheriting base class |[C++14+] Error inheriting
                   |constructors by             |base class constructors by
                   |using-declaration           |using-declaration
   Last reconfirmed|                            |2022-02-08
           Keywords|                            |rejects-valid

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Fedor Chelnokov from comment #4)
> I think `using B::B;` is not the same as redefining each constructor with
> the explicit call of base class constructor `C(int a) : B{(int)a}{}`.

Sorry I meant it should be done by static_cast<int&&>(a) which is the move
syntax rather than by a copy.


There looks like there are some differences between versions of the C++
standard too.
C++11 (before defect reports) In class.inhctor/8 had:
Each expression in the expression-list is of the form static_cast<T&&>(p),
where p is the name
of the corresponding constructor parameter and T is the declared type of p.

But that was removed it looks like with
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0136r1.html 

So the code is invalid C++11 but valid C++14 it seems. clang gets it wrong for
C++11 but gets it correct for C++14+.

GCC gets it wrong for C++14+.

  parent reply	other threads:[~2022-02-08  2:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07 11:51 [Bug c++/104418] New: " fchelnokov at gmail dot com
2022-02-07 19:21 ` [Bug c++/104418] " pinskia at gcc dot gnu.org
2022-02-07 20:43 ` fchelnokov at gmail dot com
2022-02-07 21:05 ` pinskia at gcc dot gnu.org
2022-02-07 21:24 ` fchelnokov at gmail dot com
2022-02-08  2:51 ` pinskia at gcc dot gnu.org [this message]
2022-02-08  2:53 ` [Bug c++/104418] [C++17+] " pinskia at gcc dot gnu.org
2022-02-08 18:55 ` fchelnokov at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104418-4-7RCKBFb7sV@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).