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

            Bug ID: 93989
           Summary: [c++20] Error initializing trivial types in constexpr
                    constructor
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kingoipo at gmail dot com
  Target Milestone: ---

In trying to implement p0980r1, I encountered the following error when calling
the constexpr basic_string(const _Alloc& __a) constructor:


/home/oipo-unencrypted/Programming/gcc/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign_constexpr.cc:
In function ‘consteval void test01()’:
/home/oipo-unencrypted/Programming/gcc/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign_constexpr.cc:37:
error: ‘test_type{std::__cxx11::basic_string<char, std::char_traits<char>,
__gnu_test::constexpr_allocator<char>
>::_Alloc_hider{__gnu_test::constexpr_allocator<char>{1}, ((char*)(&
v1.std::__cxx11::basic_string<char, std::char_traits<char>,
__gnu_test::constexpr_allocator<char>
>::<anonymous>.std::__cxx11::basic_string<char, std::char_traits<char>,
__gnu_test::constexpr_allocator<char> >::<unnamed union>::_M_local_buf))}, 0,
std::__cxx11::basic_string<char, std::char_traits<char>,
__gnu_test::constexpr_allocator<char> >::<unnamed union>{char [16]{0}}}’ is not
a constant expression
/home/oipo-unencrypted/Programming/gcc/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign_constexpr.cc:37:
error: ‘std::__cxx11::basic_string<char, std::char_traits<char>,
__gnu_test::constexpr_allocator<char> >(a1)’ is not a constant expression
because it refers to an incompletely initialized variable



This is reproducible by checking out the code from https://github.com/Oipo/gcc
and running the new libstdc++3 testcase
https://github.com/Oipo/gcc/blob/master/libstdc%2B%2B-v3/testsuite/21_strings/basic_string/allocator/char/copy_assign_constexpr.cc
. This can be done with "make -jN check-target-libstdc++-v3".

A noteworthy extra change is the introduction of a constexpr_allocator in
testsuite_allocator.h. 


Apologies for not being able to make a smaller reproducible case.

Reply via email to