[Bug c/15438] New: miscompilation of simple test with __errno_location ()

belyshev at lubercy dot com gcc-bugzilla@gcc.gnu.org
Fri May 14 21:29:00 GMT 2004


cat > bug.c << EOF
typedef unsigned int size_t;
extern int *__errno_location (void) __attribute__ ((__const__));
extern int printf (__const char *__restrict __format, ...);
extern void *malloc (size_t __size) __attribute__ ((__malloc__));
extern void abort (void) __attribute__ ((__noreturn__));
#define ENOMEM 12

int
main (void)
{
  void *p;
  *__errno_location () = 0;
  p = malloc (-1);
  if (*__errno_location () != ENOMEM)
	  abort ();
  return 0;
}
EOF
gcc bug.c -O
./a.out

Aborted

-- 
           Summary: miscompilation of simple test with __errno_location ()
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: belyshev at lubercy dot com
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list