public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/58490] New: __sync_bool_compare_and_swap sign bit failure
@ 2013-09-21 13:24 erikvanderwerf at gmail dot com
  2013-09-23 10:49 ` [Bug target/58490] " rearnsha at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: erikvanderwerf at gmail dot com @ 2013-09-21 13:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58490
           Summary: __sync_bool_compare_and_swap sign bit failure
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: erikvanderwerf at gmail dot com

The following lines cause an assertion failure on my arm device:

    unsigned short int x=0x8000;
    unsigned short int y=1; // or any other number
    char success = __sync_bool_compare_and_swap(&x, x, y);
    assert( success );  // ok
    assert( (x==y) );   // this fails when the highest bit in x is set

Using signed short int with negative numbers produces the same error. Using
older versions of gcc (e.g., 4.6) or when compiling for x86 it runs without
problems. 

I compiled using 'arm-linux-gnueabi-gcc-4.7 -Wall -static'. Here are some
details:

>> arm-linux-gnueabi-gcc-4.7 --version
arm-linux-gnueabi-gcc-4.7 (Debian 4.7.2-4) 4.7.2


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

* [Bug target/58490] __sync_bool_compare_and_swap sign bit failure
  2013-09-21 13:24 [Bug c/58490] New: __sync_bool_compare_and_swap sign bit failure erikvanderwerf at gmail dot com
@ 2013-09-23 10:49 ` rearnsha at gcc dot gnu.org
  2013-09-24 15:53 ` rearnsha at gcc dot gnu.org
  2013-09-27 22:16 ` erikvanderwerf at gmail dot com
  2 siblings, 0 replies; 5+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2013-09-23 10:49 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2013-09-23
     Ever confirmed|0                           |1

--- Comment #1 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Please attach a pre-processed, self-contained, test case that can be used to
demonstrate the problem.


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

* [Bug target/58490] __sync_bool_compare_and_swap sign bit failure
  2013-09-21 13:24 [Bug c/58490] New: __sync_bool_compare_and_swap sign bit failure erikvanderwerf at gmail dot com
  2013-09-23 10:49 ` [Bug target/58490] " rearnsha at gcc dot gnu.org
@ 2013-09-24 15:53 ` rearnsha at gcc dot gnu.org
  2013-09-25  8:22   ` Christian Bruel
  2013-09-27 22:16 ` erikvanderwerf at gmail dot com
  2 siblings, 1 reply; 5+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2013-09-24 15:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Can you let me know whether 

http://gcc.gnu.org/ml/gcc-patches/2013-03/msg00553.html

fixes the problem?


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

* Re: [Bug target/58490] __sync_bool_compare_and_swap sign bit failure
  2013-09-24 15:53 ` rearnsha at gcc dot gnu.org
@ 2013-09-25  8:22   ` Christian Bruel
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Bruel @ 2013-09-25  8:22 UTC (permalink / raw)
  To: gcc-bugs


On 09/24/2013 05:53 PM, rearnsha at gcc dot gnu.org wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58490
>
> --- Comment #2 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
> Can you let me know whether 
>
> http://gcc.gnu.org/ml/gcc-patches/2013-03/msg00553.html
>
> fixes the problem?
This remind me an issue I rose a while ago:
http://gcc.gnu.org/ml/gcc-help/2009-10/msg00107.html

was more or less recognized as an issue at that time, and logged as

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

with a proposal, but not clearly statued.

Best Regards

Christian





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

* [Bug target/58490] __sync_bool_compare_and_swap sign bit failure
  2013-09-21 13:24 [Bug c/58490] New: __sync_bool_compare_and_swap sign bit failure erikvanderwerf at gmail dot com
  2013-09-23 10:49 ` [Bug target/58490] " rearnsha at gcc dot gnu.org
  2013-09-24 15:53 ` rearnsha at gcc dot gnu.org
@ 2013-09-27 22:16 ` erikvanderwerf at gmail dot com
  2 siblings, 0 replies; 5+ messages in thread
From: erikvanderwerf at gmail dot com @ 2013-09-27 22:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Erik van der Werf <erikvanderwerf at gmail dot com> ---
I'm sorry, that patch definitely looks relevant, and I'd like to try it, but
somehow I did not manage to rebuild the arm-linux-gnueabi-gcc-4.7 package. 

I'm not a gcc expert, and trying to figure out how to configure the build for
cross compilation turns out to be rather time consuming, so for now I'll just
stay with gcc-4.6.

BTW I also tried the new atomic built-ins (__atomic_compare_exchange) and those
show the exact same problem.


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

end of thread, other threads:[~2013-09-27 22:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-21 13:24 [Bug c/58490] New: __sync_bool_compare_and_swap sign bit failure erikvanderwerf at gmail dot com
2013-09-23 10:49 ` [Bug target/58490] " rearnsha at gcc dot gnu.org
2013-09-24 15:53 ` rearnsha at gcc dot gnu.org
2013-09-25  8:22   ` Christian Bruel
2013-09-27 22:16 ` erikvanderwerf at gmail dot com

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