public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "piotrwn1 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/100667] New: std::tuple<A&&> cannot be constructed from A&&, if A not defined (only forward declared)
Date: Wed, 19 May 2021 08:00:54 +0000	[thread overview]
Message-ID: <bug-100667-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 100667
           Summary: std::tuple<A&&> cannot be constructed from A&&, if A
                    not defined (only forward declared)
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: piotrwn1 at gmail dot com
  Target Milestone: ---

The following code stops working when switching from gcc10 to gcc11 (gcc11.1
and trunk too) (both c++17 and c++20):


#include <utility>
#include <tuple>

class A;

std::tuple<A&&> foo(A&& a) {
    return std::tuple<A&&>(std::move(a));
}

It looks that std library code start requiring this to pass:
std::is_nothrow_constructible<A&&, A>...

Actually - I got this error when using gmock library (MOCK_METHOD), then I
extracted the problem to get SSCCE. 

Error logs (https://godbolt.org/z/TqMar3Tn6):

In file included from
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/bits/move.h:57,
                 from
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/bits/stl_pair.h:59,
                 from
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/utility:70,
                 from <source>:1:
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/type_traits: In
instantiation of 'struct std::is_nothrow_constructible<A&&, A>':
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/type_traits:133:12:  
required from 'struct std::__and_<std::is_nothrow_constructible<A&&, A> >'
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:649:66:   required
from 'static constexpr bool std::tuple<_Elements>::__nothrow_constructible()
[with _UElements = {A}; _Elements = {A&&}]'
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:733:49:   required
from 'constexpr std::tuple<_Elements>::tuple(_UElements&& ...) [with _UElements
= {A}; bool _Valid = true; typename
std::enable_if<std::tuple<_Elements>::_TCC<_Valid>::__is_implicitly_constructible<_UElements
...>(), bool>::type <anonymous> = true; _Elements = {A&&}]'
<source>:7:40:   required from here
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/type_traits:971:25: error:
invalid use of incomplete type 'class A'
  971 |       = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>;
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:4:7: note: forward declaration of 'class A'
    4 | class A;
      |       ^
In file included from <source>:2:
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple: In instantiation of
'static constexpr bool std::tuple<_Elements>::__nothrow_constructible() [with
_UElements = {A}; _Elements = {A&&}]':
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:733:49:   required
from 'constexpr std::tuple<_Elements>::tuple(_UElements&& ...) [with _UElements
= {A}; bool _Valid = true; typename
std::enable_if<std::tuple<_Elements>::_TCC<_Valid>::__is_implicitly_constructible<_UElements
...>(), bool>::type <anonymous> = true; _Elements = {A&&}]'
<source>:7:40:   required from here
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:649:73: error:
'value' is not a member of 'std::__and_<std::is_nothrow_constructible<A&&, A>
>'
  649 |             __and_<is_nothrow_constructible<_Elements,
_UElements>...>::value;
      |                                                                        
^~~~~
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple: In instantiation of
'constexpr std::tuple<_Elements>::tuple(_UElements&& ...) [with _UElements =
{A}; bool _Valid = true; typename
std::enable_if<std::tuple<_Elements>::_TCC<_Valid>::__is_implicitly_constructible<_UElements
...>(), bool>::type <anonymous> = true; _Elements = {A&&}]':
<source>:7:40:   required from here
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:733:49:   in
'constexpr' expansion of 'std::tuple<A&&>::__nothrow_constructible<A>()'
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:732:9: error:
'constexpr' call flows off the end of the function
  732 |         tuple(_UElements&&... __elements)
      |         ^~~~~
ASM generation compiler returned: 1
In file included from
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/bits/move.h:57,
                 from
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/bits/stl_pair.h:59,
                 from
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/utility:70,
                 from <source>:1:
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/type_traits: In
instantiation of 'struct std::is_nothrow_constructible<A&&, A>':
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/type_traits:133:12:  
required from 'struct std::__and_<std::is_nothrow_constructible<A&&, A> >'
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:649:66:   required
from 'static constexpr bool std::tuple<_Elements>::__nothrow_constructible()
[with _UElements = {A}; _Elements = {A&&}]'
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:733:49:   required
from 'constexpr std::tuple<_Elements>::tuple(_UElements&& ...) [with _UElements
= {A}; bool _Valid = true; typename
std::enable_if<std::tuple<_Elements>::_TCC<_Valid>::__is_implicitly_constructible<_UElements
...>(), bool>::type <anonymous> = true; _Elements = {A&&}]'
<source>:7:40:   required from here
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/type_traits:971:25: error:
invalid use of incomplete type 'class A'
  971 |       = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>;
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:4:7: note: forward declaration of 'class A'
    4 | class A;
      |       ^
In file included from <source>:2:
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple: In instantiation of
'static constexpr bool std::tuple<_Elements>::__nothrow_constructible() [with
_UElements = {A}; _Elements = {A&&}]':
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:733:49:   required
from 'constexpr std::tuple<_Elements>::tuple(_UElements&& ...) [with _UElements
= {A}; bool _Valid = true; typename
std::enable_if<std::tuple<_Elements>::_TCC<_Valid>::__is_implicitly_constructible<_UElements
...>(), bool>::type <anonymous> = true; _Elements = {A&&}]'
<source>:7:40:   required from here
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:649:73: error:
'value' is not a member of 'std::__and_<std::is_nothrow_constructible<A&&, A>
>'
  649 |             __and_<is_nothrow_constructible<_Elements,
_UElements>...>::value;
      |                                                                        
^~~~~
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple: In instantiation of
'constexpr std::tuple<_Elements>::tuple(_UElements&& ...) [with _UElements =
{A}; bool _Valid = true; typename
std::enable_if<std::tuple<_Elements>::_TCC<_Valid>::__is_implicitly_constructible<_UElements
...>(), bool>::type <anonymous> = true; _Elements = {A&&}]':
<source>:7:40:   required from here
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:733:49:   in
'constexpr' expansion of 'std::tuple<A&&>::__nothrow_constructible<A>()'
/opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/tuple:732:9: error:
'constexpr' call flows off the end of the function
  732 |         tuple(_UElements&&... __elements)
      |         ^~~~~
Execution build compiler returned: 1

             reply	other threads:[~2021-05-19  8:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19  8:00 piotrwn1 at gmail dot com [this message]
2021-05-19  9:09 ` [Bug libstdc++/100667] [11/12 Regression] " redi at gcc dot gnu.org
2021-06-18  7:56 ` ostash at ostash dot kiev.ua
2021-07-28  7:07 ` rguenth at gcc dot gnu.org
2022-04-21  7:49 ` rguenth at gcc dot gnu.org
2023-05-29 10:05 ` [Bug libstdc++/100667] [11/12/13/14 " jakub at gcc dot gnu.org
2023-05-29 11:16 ` piotrwn1 at gmail dot com
2024-03-27 12:59 ` redi at gcc dot gnu.org
2024-03-27 13:36 ` redi at gcc dot gnu.org
2024-03-27 14:02 ` redi at gcc dot gnu.org
2024-03-27 14:03 ` redi at gcc dot gnu.org
2024-03-27 14:14 ` redi at gcc dot gnu.org
2024-03-27 17:44 ` redi at gcc dot gnu.org
2024-03-28 18:26 ` cvs-commit at gcc dot gnu.org
2024-03-28 22:33 ` [Bug libstdc++/100667] [11/12/13 " redi at gcc dot gnu.org
2024-05-01 20:31 ` cvs-commit at gcc dot gnu.org

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-100667-4@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).