public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33887]  New: Reference to bitfield gets wrong value when optimizing
@ 2007-10-24 23:44 ian at airs dot com
  2007-10-24 23:51 ` [Bug c++/33887] " pinskia at gcc dot gnu dot org
                   ` (48 more replies)
  0 siblings, 49 replies; 50+ messages in thread
From: ian at airs dot com @ 2007-10-24 23:44 UTC (permalink / raw)
  To: gcc-bugs

This C++ test case passes a bitfield value to a function which expects a const
reference.  When optimizing, the function gets the wrong value: it gets the
value 0x1000000, which is an acceptable value for a 24-bit bitfield, but is the
wrong value for extending the bitfield out to a 32-bit integer.  This failure
happens on i686-pc-linux-gnu with -O2.  The test passes without optimization.

extern "C" void abort() __attribute__ ((noreturn));

template<typename t1, typename t2>
void fn(const t1&, const t2&) __attribute__ ((noinline));

template<typename t1, typename t2>
void fn(const t1& v1, const t2& v2)
{
  if (v1 != v2)
    abort();
}

struct s
{
  unsigned long long f1 : 40;
  unsigned int f2 : 24;
};

s sv;

int main()
{
  sv.f1 = 0;
  sv.f2 = (1 << 24) - 1;
  fn(sv.f1, 0);
  fn(sv.f2, (1 << 24) - 1);
  ++sv.f2;
  fn(sv.f2, 0);
  return 0;
}


-- 
           Summary: Reference to bitfield gets wrong value when optimizing
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


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


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

end of thread, other threads:[~2009-03-31  0:36 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-24 23:44 [Bug c++/33887] New: Reference to bitfield gets wrong value when optimizing ian at airs dot com
2007-10-24 23:51 ` [Bug c++/33887] " pinskia at gcc dot gnu dot org
2007-10-25  5:07 ` ian at airs dot com
2007-10-25  5:22 ` pinskia at gcc dot gnu dot org
2007-10-25 13:25 ` ian at airs dot com
2007-12-08 20:07 ` [Bug middle-end/33887] [4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
2007-12-11 12:38 ` rguenth at gcc dot gnu dot org
2007-12-11 12:50 ` rguenth at gcc dot gnu dot org
2007-12-11 13:08 ` [Bug c++/33887] " rguenth at gcc dot gnu dot org
2007-12-11 13:32 ` [Bug c++/33887] [4.1/4.2/4.3 " rguenth at gcc dot gnu dot org
2007-12-11 13:35 ` rguenth at gcc dot gnu dot org
2007-12-11 15:55 ` rguenth at gcc dot gnu dot org
2007-12-11 23:57 ` janis at gcc dot gnu dot org
2007-12-12 20:53 ` mmitchel at gcc dot gnu dot org
2007-12-12 22:04 ` janis at gcc dot gnu dot org
2007-12-12 22:47 ` rguenth at gcc dot gnu dot org
2007-12-14 14:32 ` bonzini at gnu dot org
2007-12-14 14:36 ` rguenther at suse dot de
2008-01-02 15:34 ` rguenth at gcc dot gnu dot org
2008-01-11  7:29 ` aoliva at gcc dot gnu dot org
2008-01-14 16:55 ` rguenth at gcc dot gnu dot org
2008-01-14 19:10 ` rguenth at gcc dot gnu dot org
2008-01-14 19:19 ` rguenth at gcc dot gnu dot org
2008-01-14 21:35 ` aoliva at gcc dot gnu dot org
2008-01-15 10:11 ` rguenth at gcc dot gnu dot org
2008-01-15 14:12 ` rguenth at gcc dot gnu dot org
2008-01-15 14:55 ` rguenth at gcc dot gnu dot org
2008-01-18 18:45 ` aoliva at gcc dot gnu dot org
2008-01-18 19:22 ` aoliva at gcc dot gnu dot org
2008-01-18 19:46 ` aoliva at gcc dot gnu dot org
2008-01-18 22:21 ` rguenth at gcc dot gnu dot org
2008-01-19  1:05 ` aoliva at gcc dot gnu dot org
2008-01-21  9:35 ` rguenth at gcc dot gnu dot org
2008-01-21  9:44 ` rguenth at gcc dot gnu dot org
2008-01-23 15:04 ` rguenth at gcc dot gnu dot org
2008-01-25  7:51 ` mmitchel at gcc dot gnu dot org
2008-01-25 12:15 ` rguenth at gcc dot gnu dot org
2008-01-25 12:56 ` [Bug c++/33887] [4.1/4.2 " rguenth at gcc dot gnu dot org
2008-01-25 20:57 ` tromey at gcc dot gnu dot org
2008-01-25 21:41 ` rguenth at gcc dot gnu dot org
2008-02-01 17:02 ` jsm28 at gcc dot gnu dot org
2008-02-07 18:04 ` rguenth at gcc dot gnu dot org
2008-03-12 14:27 ` rguenth at gcc dot gnu dot org
2008-03-12 14:31 ` rguenth at gcc dot gnu dot org
2008-04-18 14:04 ` aldot at gcc dot gnu dot org
2008-04-18 15:07 ` rguenth at gcc dot gnu dot org
2008-05-07 19:44 ` rguenth at gcc dot gnu dot org
2008-05-19 20:31 ` jsm28 at gcc dot gnu dot org
2008-07-04 22:53 ` [Bug c++/33887] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-31  0:36 ` jsm28 at gcc dot gnu dot 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).