public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "e.tadeu at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/106067] New: Error on implicit conversion to std::function: 'static constexpr bool std::_Function_handler<...>...' used before its definition
Date: Thu, 23 Jun 2022 19:19:07 +0000	[thread overview]
Message-ID: <bug-106067-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 106067
           Summary: Error on implicit conversion to std::function: 'static
                    constexpr bool std::_Function_handler<...>...' used
                    before its definition
           Product: gcc
           Version: 11.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: e.tadeu at gmail dot com
  Target Milestone: ---

The following code started failing on GCC 11.3 (also fails on GCC 12):

    #include <functional>

    double fn();

    template <double (*T)(std::function<double()>)>
    void caller()
    {
        auto f = T(fn);
        // auto f = T(std::function<double()>(fn));  // workaround (this works)
    }


The snippet is also here: https://godbolt.org/z/zh7nr7vKc

The full error is:

        In file included from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/move.h:57,
                                         from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/stl_function.h:60,
                                         from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/functional:49,
                                         from <source>:1:
        /opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/type_traits: In
instantiation of 'struct std::is_trivially_copyable<double (*)()>':
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:69:12:
  required from 'struct std::__is_location_invariant<double (*)()>'
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:125:38:
  required from 'const bool std::_Function_base::_Base_manager<double
(*)()>::__stored_locally'
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:130:8:
  required from 'class std::_Function_base::_Base_manager<double (*)()>'
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:260:11:
  required from 'class std::_Function_handler<double(), double (*)()>'
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:436:65:
  required from 'std::function<_Res(_ArgTypes ...)>::function(_Functor&&) [with
_Functor = double (*)(); _Constraints = void; _Res = double; _ArgTypes = {}]'
        <source>:8:15:   required from here
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/type_traits:713:52: error:
non-constant condition for static assertion
          713 |      
static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
                  |                    
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/type_traits:713:52: error:
'constexpr std::true_type
std::__is_complete_or_unbounded(std::__type_identity<_Tp>) [with _Tp = double
(*)(); long unsigned int <anonymous> = 8; std::true_type =
std::integral_constant<bool, true>]' used before its definition
        In file included from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/functional:59,
                                         from <source>:1:
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h: In
instantiation of 'std::function<_Res(_ArgTypes ...)>::function(_Functor&&)
[with _Functor = double (*)(); _Constraints = void; _Res = double; _ArgTypes =
{}]':
        <source>:8:15:   required from here
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:436:72:
error: 'static constexpr bool std::_Function_handler<_Res(_ArgTypes ...),
_Functor>::_S_nothrow_init() [with _Fn = double (*)(); _Res = double; _Functor
= double (*)(); _ArgTypes = {}]' used before its definition
          436 |         noexcept(_Handler<_Functor>::template
_S_nothrow_init<_Functor>())
                  |                 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
        ASM generation compiler returned: 1
        In file included from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/move.h:57,
                                         from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/stl_function.h:60,
                                         from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/functional:49,
                                         from <source>:1:
        /opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/type_traits: In
instantiation of 'struct std::is_trivially_copyable<double (*)()>':
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:69:12:
  required from 'struct std::__is_location_invariant<double (*)()>'
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:125:38:
  required from 'const bool std::_Function_base::_Base_manager<double
(*)()>::__stored_locally'
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:130:8:
  required from 'class std::_Function_base::_Base_manager<double (*)()>'
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:260:11:
  required from 'class std::_Function_handler<double(), double (*)()>'
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:436:65:
  required from 'std::function<_Res(_ArgTypes ...)>::function(_Functor&&) [with
_Functor = double (*)(); _Constraints = void; _Res = double; _ArgTypes = {}]'
        <source>:8:15:   required from here
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/type_traits:713:52: error:
non-constant condition for static assertion
          713 |      
static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
                  |                    
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/type_traits:713:52: error:
'constexpr std::true_type
std::__is_complete_or_unbounded(std::__type_identity<_Tp>) [with _Tp = double
(*)(); long unsigned int <anonymous> = 8; std::true_type =
std::integral_constant<bool, true>]' used before its definition
        In file included from
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/functional:59,
                                         from <source>:1:
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h: In
instantiation of 'std::function<_Res(_ArgTypes ...)>::function(_Functor&&)
[with _Functor = double (*)(); _Constraints = void; _Res = double; _ArgTypes =
{}]':
        <source>:8:15:   required from here
       
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/bits/std_function.h:436:72:
error: 'static constexpr bool std::_Function_handler<_Res(_ArgTypes ...),
_Functor>::_S_nothrow_init() [with _Fn = double (*)(); _Res = double; _Functor
= double (*)(); _ArgTypes = {}]' used before its definition
          436 |         noexcept(_Handler<_Functor>::template
_S_nothrow_init<_Functor>())
                  |                 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
        Execution build compiler returned: 1

             reply	other threads:[~2022-06-23 19:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 19:19 e.tadeu at gmail dot com [this message]
2022-06-23 22:40 ` [Bug libstdc++/106067] " redi at gcc dot gnu.org
2023-06-23 13:24 ` [Bug libstdc++/106067] [11/12/13/14 Regression] " redi 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-106067-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).