public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "andrzej at rpi dot pl" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107735] New: Inconsistent error messages for std::array out of bound Date: Thu, 17 Nov 2022 15:00:00 +0000 [thread overview] Message-ID: <bug-107735-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107735 Bug ID: 107735 Summary: Inconsistent error messages for std::array out of bound Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: andrzej at rpi dot pl Target Milestone: --- Created attachment 53919 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53919&action=edit Preprocessed file The second and third lines of following code produce different `out of bound` compile errors, one pointing to the original line, the other pointing to a line inside standard library that is trying to access internal (non-std::) array ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ constexpr std::array<int, 3> array = {1, 2, 3}; constexpr int v1 = array[3]; constexpr int v2 = array[4]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Compilation line: `g++-12 a-minimal_example.ii` Compiler output: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ minimal_example.cpp:6:27: error: array subscript value ‘3’ is outside the bounds of array type ‘std::__array_traits<int, 3>::_Type’ {aka ‘const int [3]’} 6 | constexpr int v1 = array[3]; | ^ In file included from minimal_example.cpp:1: minimal_example.cpp:9:27: in ‘constexpr’ expansion of ‘array.std::array<int, 3>::operator[](4)’ /usr/include/c++/12/array:219:25: in ‘constexpr’ expansion of ‘std::__array_traits<int, 3>::_S_ref(((const std::array<int, 3>*)this)->std::array<int, 3>::_M_elems, __n)’ /usr/include/c++/12/array:61:36: error: array subscript value ‘4’ is outside the bounds of array type ‘std::__array_traits<int, 3>::_Type’ {aka ‘const int [3]’} 61 | { return const_cast<_Tp&>(__t[__n]); } | ~~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GCC version: gcc-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0 System version: Linux 5.15.0-52-generic #58-Ubuntu SMP x86_64 GCC build options: Configured with: ../src/configure -v --with-pkgversion='Ubuntu 12.1.0-2ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
next reply other threads:[~2022-11-17 15:00 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-17 15:00 andrzej at rpi dot pl [this message] 2022-11-17 16:31 ` [Bug c++/107735] " redi at gcc dot gnu.org 2022-11-17 22:24 ` pinskia at gcc dot gnu.org 2022-11-18 0:46 ` [Bug c++/107735] Inconsistent error messages for std::array out of bound due to taking the address of one-past-the-end is valid redi at gcc dot gnu.org 2022-11-18 0:49 ` pinskia 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-107735-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: linkBe 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).