[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#503204: gcc-4.1: erroneously emits warning on C99-required #pragma STDC FENV_ACCESS



Package: gcc-4.1
Version: 4.1.1-21
Severity: important

Hi,

C99 requires that code that tests floating-point state flags (or frobs 
other bits of the floating-point environment) calls #pragma STDC 
FENV_ACCESS ON:

"If part of an application tests floating-point status flags, sets 
floating-point control modes, or runs under non-default mode settings, 
but was translated with the state for the FENV_ACCESS pragma off, the 
behavior is undefined." (7.6.1.2)

Yet, if you do this in gcc with -Wall turned on, you get a warning 
message:

matthew@b144-mcv1-mlt:/tmp$ cat test.c 
#include <stdio.h>
#include <fenv.h>

int main(void)
{
  #pragma STDC FENV_ACCESS ON

  if(feclearexcept(FE_ALL_EXCEPT))
    printf("feclearexcept failed\n");
  else printf("feclearexcept succeeded\n");

  return 0;
}
matthew@b144-mcv1-mlt:/tmp$ gcc -std=gnu99 -Wall test.c -lm
test.c: In function ‘main’:
test.c:6: warning: ignoring #pragma STDC FENV_ACCESS
matthew@b144-mcv1-mlt:/tmp$ ./a.out 
feclearexcept succeeded
matthew@b144-mcv1-mlt:/tmp$ 

It's obviously buggy to emit a warning on standards-mandated behaviour! 
I know you can turn this warning off with -Wno-unknown-pragmas, but 
that's not something you want to be doing in production code.

Regards,

Matthew

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.20-2-macpro-amd64
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)

Versions of packages gcc-4.1 depends on:
ii  binutils               2.17-3            The GNU assembler, linker and bina
ii  cpp-4.1                4.1.1-21          The GNU C preprocessor
ii  gcc-4.1-base           4.1.1-21          The GNU Compiler Collection (base 
ii  libc6                  2.3.6.ds1-13etch7 GNU C Library: Shared libraries
ii  libgcc1                1:4.1.1-21        GCC support library
ii  libssp0                4.1.1-21          GCC stack smashing protection libr

Versions of packages gcc-4.1 recommends:
ii  libc6-dev              2.3.6.ds1-13etch7 GNU C Library: Development Librari
pn  libmudflap0-dev        <none>            (no description available)

-- no debconf information



Reply to: