public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/49144] New: [4.6/4.7 regression] miscompiled reverse_iterator?
@ 2011-05-24 17:21 doko at ubuntu dot com
  2011-05-24 17:45 ` [Bug tree-optimization/49144] " paolo.carlini at oracle dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: doko at ubuntu dot com @ 2011-05-24 17:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49144

           Summary: [4.6/4.7 regression] miscompiled reverse_iterator?
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: doko@ubuntu.com


[forwarded from http://bugs.debian.org/PR627795]

seen with 4.6 r174102 and trunk r173903

The attached test program is supposed to print -42, and does so when compiled
with g++-4.4 or g++-4.5. However, it outputs random junk when compiled with
g++-4.6:

$ g++ -Wall -O2 test.cxx
$ ./a.out
31
$ ./a.out
207
$ ./a.out
79


#include <iostream>

int f()
{
    unsigned char data[3] = { 42, 42, 42 };
    unsigned char *begin = data;
    unsigned char *end = data + 3;
    std::reverse_iterator<unsigned char *> reversed(end);
    for (; begin < end; begin++, reversed++)
        if (*reversed != 42)
            return *reversed;
    return -42;
}

int main(int argc, char ** argv)
{
    std::cout << f() << "\n";
}


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

end of thread, other threads:[~2011-05-25 11:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-24 17:21 [Bug other/49144] New: [4.6/4.7 regression] miscompiled reverse_iterator? doko at ubuntu dot com
2011-05-24 17:45 ` [Bug tree-optimization/49144] " paolo.carlini at oracle dot com
2011-05-24 23:27 ` jakub at gcc dot gnu.org
2011-05-25  3:35 ` hjl.tools at gmail dot com
2011-05-25  8:58 ` rguenth at gcc dot gnu.org
2011-05-25 11:29 ` rguenth 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).