public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/65352] array<T,0>::begin()/end() etc. forms a null reference and breaks on clang+ubsan Date: Sun, 08 Mar 2015 18:13:00 -0000 [thread overview] Message-ID: <bug-65352-4-vFM9jvEgJW@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-65352-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65352 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Oops, that should be: --- a/libstdc++-v3/include/std/array +++ b/libstdc++-v3/include/std/array @@ -58,9 +58,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { struct _Type { }; - static constexpr _Tp& - _S_ref(const _Type&, std::size_t) noexcept - { return *static_cast<_Tp*>(nullptr); } + static _Tp& + _S_ref(const _Type& __t, std::size_t) noexcept + { return reinterpret_cast<_Tp&>(const_cast<_Type&>(__t)); } }; /** I think it's OK to make it non-constexpr, because _S_ref only needs to be constexpr for functions which access an element, which are also invalid for the zero-size array.
next prev parent reply other threads:[~2015-03-08 18:13 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-03-08 17:43 [Bug libstdc++/65352] New: " rs2740 at gmail dot com 2015-03-08 18:09 ` [Bug libstdc++/65352] " redi at gcc dot gnu.org 2015-03-08 18:13 ` redi at gcc dot gnu.org [this message] 2015-03-13 3:15 ` rs2740 at gmail dot com 2015-05-28 9:43 ` redi at gcc dot gnu.org 2015-05-28 12:34 ` redi at gcc dot gnu.org 2015-05-28 16:00 ` redi at gcc dot gnu.org 2015-05-28 16:28 ` redi at gcc dot gnu.org 2015-05-28 16:32 ` 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-65352-4-vFM9jvEgJW@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).