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

3440910457 at qq dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |3440910457 at qq dot com

--- Comment #4 from 3440910457 at qq dot com ---
This bug is still exists in GCC 15.2

See here: https://godbolt.org/z/9x6E9eeoq

The bug may be not related to the libstdc++ <functional>. It is maybe actually
related to the instantiation sequence of the template function.

The following code started failing on GCC 14.1 (also fails on GCC 15.2)



    template <typename T> struct Empty {};

    template <typename T>
    constexpr bool test(T) noexcept { return true; }

    template <typename T>
    struct always_true {
        static constexpr bool value = true;
        static_assert(test(Empty<T>{}), "BUG");
    };

    template <typename T>
    struct AAA {
        template <typename U, bool = always_true<U>::value>
        AAA(U) {}
    };

    template <int (*U) (AAA<int>)>
    void test_function() {
        auto r = U(AAA<int>(1));
    }

    int main() {
        return 0;
    }


The full error is:

<source>: In instantiation of 'struct always_true<int>':
<source>:15:50:   required by substitution of 'template<class U, bool
<anonymous> > AAA<int>::AAA(U) [with U = int; bool <anonymous> = <missing>]'
   15 |     template <typename U, bool = always_true<U>::value>
      |                                                  ^~~~~
<source>:21:16:   required from here
   21 |     auto r = U(AAA<int>(1));
      |                ^~~~~~~~~~~
<source>:10:23: error: non-constant condition for static assertion
   10 |     static_assert(test(Empty<T>{}), "BUG");
      |                   ~~~~^~~~~~~~~~~~
<source>:10:23: error: 'constexpr bool test(T) [with T = Empty<int>]' used
before its definition
Compiler returned: 1

Reply via email to