public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67795] New: Wrong code generated for conditional expression with cast
@ 2015-10-01 10:52 frankhb1989 at gmail dot com
  2015-10-01 11:14 ` [Bug c++/67795] " trippels at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: frankhb1989 at gmail dot com @ 2015-10-01 10:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67795
           Summary: Wrong code generated for conditional expression with
                    cast
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: frankhb1989 at gmail dot com
  Target Milestone: ---

Case:
// g++ -std=c++1y
#include <iostream>
#include <string>
#include <experimental/string_view>

using namespace std;
using namespace experimental;

string_view&
erase_left(size_t n, string_view& s)
{
        return static_cast<string_view&>(n != 0 ? (s.remove_prefix(n), s) : s);
//      return n != 0 ? (s.remove_prefix(n), s) : s;
}

int main()
{
        string_view sv("abcde");
        cout << erase_left(3, sv).to_string() << endl; // expected "de"
}

The output is garbage, using i686-w64-mingw32-g++ from MSYS2. However,
x86_64-w64-mingw32-clang++ is OK. So I suspect it is a frontend bug.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-02-01 15:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-01 10:52 [Bug c++/67795] New: Wrong code generated for conditional expression with cast frankhb1989 at gmail dot com
2015-10-01 11:14 ` [Bug c++/67795] " trippels at gcc dot gnu.org
2015-10-01 12:28 ` frankhb1989 at gmail dot com
2015-10-01 12:42 ` frankhb1989 at gmail dot com
2015-10-01 12:52 ` rguenth at gcc dot gnu.org
2015-10-01 12:56 ` frankhb1989 at gmail dot com
2015-10-01 12:57 ` glisse at gcc dot gnu.org
2015-10-01 13:06 ` frankhb1989 at gmail dot com
2015-10-01 13:09 ` frankhb1989 at gmail dot com
2015-10-01 13:13 ` frankhb1989 at gmail dot com
2021-10-11  1:50 ` pinskia at gcc dot gnu.org
2021-12-09  9:12 ` marxin at gcc dot gnu.org
2022-02-01 15:56 ` marxin at gcc dot gnu.org

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).