public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "terra at gnome dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/109517] New: Failure to compile constexpr std::copy with -D_GLIBCXX_DEBUG
Date: Fri, 14 Apr 2023 19:40:54 +0000	[thread overview]
Message-ID: <bug-109517-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109517
           Summary: Failure to compile constexpr std::copy with
                    -D_GLIBCXX_DEBUG
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: terra at gnome dot org
  Target Milestone: ---

Created attachment 54861
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54861&action=edit
Preprocessed source code

The following program fails to compile with -std=gnu++20 -D_GLIBCXX_DEBUG
due to something in the library not being constexpr.

It compiles just fine without -D_GLIBCXX_DEBUG.  FWIW, clang 15 sees no problem
(without -D...) other than "farm" being unused.


------------------------------------------------------------------

#include <array>
#include <algorithm>
#include <initializer_list>

class wrapper : public std::array<const char *, 3> {
public:
  constexpr wrapper(std::initializer_list<const char *> list) {
    std::copy(list.begin(), list.end(), this->begin());
  }
};

constexpr wrapper farm = { "moo", "oink", "baa" };

------------------------------------------------------------------


/usr/local/products/gcc/12.1.0/bin/g++ -v  -std=gnu++20 -D_GLIBCXX_DEBUG -c
uuu.C
Using built-in specs.
COLLECT_GCC=/usr/local/products/gcc/12.1.0/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/products/gcc/12.1.0/lib/gcc/x86_64-suse-linux/12.1.0/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../../gcc-12.1.0/configure --enable-languages=c,c++,fortran
--enable-targets=x86_64-suse-linux,i686-suse-linux
--prefix=/usr/local/products/gcc/12.1.0 --with-gnu-as
--with-as=/usr/local/products/gcc/binutils-2.38/bin/as
--with-ld=/usr/local/products/gcc/binutils-2.38/bin/ld.gold --enable-link-mutex
--enable-gnu-indirect-functions --enable-linux-futex --enable-threads=posix
--enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new
x86_64-suse-linux
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.1.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-std=gnu++20' '-D' '_GLIBCXX_DEBUG' '-shared-libgcc'
'-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /usr/local/products/gcc/12.1.0/lib/gcc/x86_64-suse-linux/12.1.0/cc1plus -quiet
-v -D_GNU_SOURCE -D _GLIBCXX_DEBUG uuu.C -quiet -dumpdir a- -dumpbase uuu.C
-dumpbase-ext .C -mtune=generic -march=x86-64 -std=gnu++20 -version -o
/tmp/cc5WkAgd.s
GNU C++20 (GCC) version 12.1.0 (x86_64-suse-linux)
        compiled by GNU C version 12.1.0, GMP version 6.1.0, MPFR version
3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/usr/local/products/gcc/12.1.0/lib64/gcc/x86_64-suse-linux/12.1.0/../../../../x86_64-suse-linux/include"
#include "..." search starts here:
#include <...> search starts here:

/usr/local/products/gcc/12.1.0/lib64/gcc/x86_64-suse-linux/12.1.0/../../../../include/c++/12.1.0

/usr/local/products/gcc/12.1.0/lib64/gcc/x86_64-suse-linux/12.1.0/../../../../include/c++/12.1.0/x86_64-suse-linux

/usr/local/products/gcc/12.1.0/lib64/gcc/x86_64-suse-linux/12.1.0/../../../../include/c++/12.1.0/backward
 /usr/local/products/gcc/12.1.0/lib64/gcc/x86_64-suse-linux/12.1.0/include
 /usr/local/include
 /usr/local/products/gcc/12.1.0/include

/usr/local/products/gcc/12.1.0/lib64/gcc/x86_64-suse-linux/12.1.0/include-fixed
 /usr/include
End of search list.
GNU C++20 (GCC) version 12.1.0 (x86_64-suse-linux)
        compiled by GNU C version 12.1.0, GMP version 6.1.0, MPFR version
3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9e0c9110c7d4f6deb64439dc23f707eb
In file included from
/usr/local/products/gcc/12.1.0/include/c++/12.1.0/debug/stl_iterator.h:32,
                 from
/usr/local/products/gcc/12.1.0/include/c++/12.1.0/bits/stl_iterator.h:2559,
                 from
/usr/local/products/gcc/12.1.0/include/c++/12.1.0/bits/stl_algobase.h:67,
                 from
/usr/local/products/gcc/12.1.0/include/c++/12.1.0/array:43,
                 from uuu.C:1:
uuu.C:12:49:   in ‘constexpr’ expansion of ‘wrapper(std::initializer_list<const
char*>{((const char* const*)(& const char* const [3]{((const char*)"moo"),
((const char*)"oink"), ((const char*)"baa")})), 3})’
uuu.C:8:14:   in ‘constexpr’ expansion of ‘std::copy<const char* const*, const
char**>(list.std::initializer_list<const char*>::begin(),
list.std::initializer_list<const char*>::end(),
((wrapper*)this)->wrapper::<anonymous>.std::array<const char*, 3>::begin())’
/usr/local/products/gcc/12.1.0/include/c++/12.1.0/bits/stl_algobase.h:617:7:  
in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range<const char*
const*>(__first, __last, __dist)’
/usr/local/products/gcc/12.1.0/include/c++/12.1.0/debug/helper_functions.h:234:31:
  in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range_aux<const char*
const*>(__first, __last, (* & __dist), (_Integral(), _Integral()))’
/usr/local/products/gcc/12.1.0/include/c++/12.1.0/debug/helper_functions.h:200:29:
  in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range_aux<const char*
const*>(__first, __last, (std::input_iterator_tag(),
std::input_iterator_tag()))’
/usr/local/products/gcc/12.1.0/include/c++/12.1.0/debug/helper_functions.h:136:20:
error: ‘(((const char* const*)(&<anonymous>)) == 0)’ is not a constant
expression
  136 |     { return __ptr == 0; }
      |              ~~~~~~^~~~

             reply	other threads:[~2023-04-14 19:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 19:40 terra at gnome dot org [this message]
2023-04-18  9:52 ` [Bug libstdc++/109517] " redi at gcc dot gnu.org
2023-04-18  9:55 ` 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-109517-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).