[Bug 434527] Re: [PR42553] Compiled program misbehaves

Bug Watch Updater 434527 at bugs.launchpad.net
Sat Mar 23 21:29:32 UTC 2013


** Changed in: gcc
   Importance: Unknown => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-4.4 in Ubuntu.
https://bugs.launchpad.net/bugs/434527

Title:
  [PR42553] Compiled program misbehaves

Status in The GNU Compiler Collection:
  Invalid
Status in “gcc-4.4” package in Ubuntu:
  Invalid

Bug description:
  Ubuntu 10.9 Alpha 6, amd64, Core2Duo processor.

  druid at lambda-laptop:~/tmp$ gcc-4.4 -v
  Using built-in specs.
  Target: x86_64-linux-gnu
  Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
  Thread model: posix
  gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu1)

  I have a program that works well with 4.3 (prints zero) but prints 2
  with 4.4. It's quite obvious from return statement that
  atomic_test_and_reset_bit function cannot return anything except for 0
  and 1...

  #include <stdbool.h>
  #include <stdio.h>

  static bool atomic_test_and_reset_bit(unsigned long *v,unsigned long bit) {
    bool res;

    __asm__ __volatile__( "btr %2,%1\n"
                          "adc $0,%0\n"
                          :"=r"(res), "=m"(*v)
                          :"r"(bit), "r"(0))  ;
    return res ? 1 : 0;
  }

  int main(void)
  {
    unsigned long flags = 0;
    int j;

    j = atomic_test_and_reset_bit(&flags, 2);

    printf("%d\n", j);

    return 0;
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/434527/+subscriptions




More information about the foundations-bugs mailing list