public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Bug in restricted pointers (C99)?
@ 2004-06-07  0:32 The Thodes
  2004-06-08 19:00 ` Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: The Thodes @ 2004-06-07  0:32 UTC (permalink / raw)
  To: gcc-bugs

GCC 3.3.1 on i686-pc-cygwin does not squawk if I try to pass the same
address twice to a fn taking two restrict-qualified ptrs as args... (src,
output follows)
--output starts here--
--part 1 of 2 starts (compiler output)--
$ gcc -std=c99 -gstabs+3 -Wall -Wstrict-aliasing -fstrict-aliasing test2.c
do_i
t.c -o test2

--part 1 of 2 ends--
--part 2 of 2 starts (program output)--
$ ./test2
foo = 5, bar = 5
--part 2 of 2 ends--
--output ends--
--source begins--
# 1 "test2.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test2.c"
extern void do_it (int *restrict foo, int *restrict bar);

int main (void)
{
  int a = 5;

  do_it (&a, &a);
  return 0;
}
# 1 "do_it.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "do_it.c"
# 1 "/usr/include/stdio.h" 1 3 4
# 29 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/_ansi.h" 1 3 4
# 15 "/usr/include/_ansi.h" 3 4
# 1 "/usr/include/newlib.h" 1 3 4
# 16 "/usr/include/_ansi.h" 2 3 4
# 1 "/usr/include/sys/config.h" 1 3 4



# 1 "/usr/include/machine/ieeefp.h" 1 3 4
# 5 "/usr/include/sys/config.h" 2 3 4
# 151 "/usr/include/sys/config.h" 3 4
# 1 "/usr/include/cygwin/config.h" 1 3 4
# 152 "/usr/include/sys/config.h" 2 3 4
# 17 "/usr/include/_ansi.h" 2 3 4
# 30 "/usr/include/stdio.h" 2 3 4




# 1 "/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include/stddef.h" 1 3 4
# 220 "/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include/stddef.h" 3 4
typedef unsigned int size_t;
# 35 "/usr/include/stdio.h" 2 3 4


# 1 "/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include/stdarg.h" 1 3 4
# 44 "/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 38 "/usr/include/stdio.h" 2 3 4







# 1 "/usr/include/sys/reent.h" 1 3 4
# 14 "/usr/include/sys/reent.h" 3 4
# 1 "/usr/include/sys/_types.h" 1 3 4
# 12 "/usr/include/sys/_types.h" 3 4
typedef long _off_t;
__extension__ typedef long long _off64_t;


typedef int _ssize_t;





# 1 "/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include/stddef.h" 1 3 4
# 361 "/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include/stddef.h" 3 4
typedef unsigned int wint_t;
# 23 "/usr/include/sys/_types.h" 2 3 4


typedef struct
{
  int __count;
  union
  {
    wint_t __wch;
    unsigned char __wchb[4];
  } __value;
} _mbstate_t;

typedef int _flock_t;


typedef void *_iconv_t;
# 15 "/usr/include/sys/reent.h" 2 3 4




typedef unsigned long __ULong;
# 40 "/usr/include/sys/reent.h" 3 4
struct _Bigint
{
  struct _Bigint *_next;
  int _k, _maxwds, _sign, _wds;
  __ULong _x[1];
};


struct __tm
{
  int __tm_sec;
  int __tm_min;
  int __tm_hour;
  int __tm_mday;
  int __tm_mon;
  int __tm_year;
  int __tm_wday;
  int __tm_yday;
  int __tm_isdst;
};







struct _on_exit_args {
        void * _fnargs[32];
        __ULong _fntypes;

};
# 80 "/usr/include/sys/reent.h" 3 4
struct _atexit {
        struct _atexit *_next;
        int _ind;
        void (*_fns[32])(void);
        struct _on_exit_args _on_exit_args;
};
# 95 "/usr/include/sys/reent.h" 3 4
struct __sbuf {
        unsigned char *_base;
        int _size;
};






typedef long _fpos_t;



typedef _off64_t _fpos64_t;
# 160 "/usr/include/sys/reent.h" 3 4
struct __sFILE {
  unsigned char *_p;
  int _r;
  int _w;
  short _flags;
  short _file;
  struct __sbuf _bf;
  int _lbfsize;






  void * _cookie;

  _ssize_t __attribute__((__cdecl__)) (*_read) (void * _cookie, char *_buf,
int _n);
  _ssize_t __attribute__((__cdecl__)) (*_write) (void * _cookie, const char
*_buf, int _n);

  _fpos_t __attribute__((__cdecl__)) (*_seek) (void * _cookie, _fpos_t
_offset, int _whence);
  int __attribute__((__cdecl__)) (*_close) (void * _cookie);


  struct __sbuf _ub;
  unsigned char *_up;
  int _ur;


  unsigned char _ubuf[3];
  unsigned char _nbuf[1];


  struct __sbuf _lb;


  int _blksize;
  int _offset;


  struct _reent *_data;



  _flock_t _lock;

};


struct __sFILE64 {
  unsigned char *_p;
  int _r;
  int _w;
  short _flags;
  short _file;
  struct __sbuf _bf;
  int _lbfsize;

  struct _reent *_data;


  void * _cookie;

  _ssize_t __attribute__((__cdecl__)) (*_read) (void * _cookie, char *_buf,
int _n);
  _ssize_t __attribute__((__cdecl__)) (*_write) (void * _cookie, const char
*_buf, int _n);

  _fpos_t __attribute__((__cdecl__)) (*_seek) (void * _cookie, _fpos_t
_offset, int _whence);
  int __attribute__((__cdecl__)) (*_close) (void * _cookie);


  struct __sbuf _ub;
  unsigned char *_up;
  int _ur;


  unsigned char _ubuf[3];
  unsigned char _nbuf[1];


  struct __sbuf _lb;


  int _blksize;
  int _flags2;

  _off64_t _offset;
  _fpos64_t __attribute__((__cdecl__)) (*_seek64) (void * _cookie, _fpos64_t
_offset, int _whence);


  _flock_t _lock;

};
typedef struct __sFILE64 __FILE;




struct _glue
{
  struct _glue *_next;
  int _niobs;
  __FILE *_iobs;
};
# 284 "/usr/include/sys/reent.h" 3 4
struct _rand48 {
  unsigned short _seed[3];
  unsigned short _mult[3];
  unsigned short _add;




};
# 533 "/usr/include/sys/reent.h" 3 4
struct _reent
{
  int _errno;




  __FILE *_stdin, *_stdout, *_stderr;

  int _inc;
  char _emergency[25];

  int _current_category;
  const char *_current_locale;

  int __sdidinit;

  void __attribute__((__cdecl__)) (*__cleanup) (struct _reent *);


  struct _Bigint *_result;
  int _result_k;
  struct _Bigint *_p5s;
  struct _Bigint **_freelist;


  int _cvtlen;
  char *_cvtbuf;

  union
    {
      struct
        {
          unsigned int _unused_rand;
          char * _strtok_last;
          char _asctime_buf[26];
          struct __tm _localtime_buf;
          int _gamma_signgam;
          __extension__ unsigned long long _rand_next;
          struct _rand48 _r48;
          _mbstate_t _mblen_state;
          _mbstate_t _mbtowc_state;
          _mbstate_t _wctomb_state;
          char _l64a_buf[8];
          char _signal_buf[24];
          int _getdate_err;
          _mbstate_t _mbrlen_state;
          _mbstate_t _mbrtowc_state;
          _mbstate_t _mbsrtowcs_state;
          _mbstate_t _wcrtomb_state;
          _mbstate_t _wcsrtombs_state;
        } _reent;



      struct
        {

          unsigned char * _nextf[30];
          unsigned int _nmalloc[30];
        } _unused;
    } _new;


  struct _atexit *_atexit;
  struct _atexit _atexit0;


  void (**(_sig_func))(int);




  struct _glue __sglue;
  __FILE __sf[3];
};
# 730 "/usr/include/sys/reent.h" 3 4
extern struct _reent *_impure_ptr ;

void _reclaim_reent (struct _reent *);







  struct _reent * __attribute__((__cdecl__)) __getreent (void);
# 46 "/usr/include/stdio.h" 2 3 4
# 1 "/usr/include/sys/types.h" 1 3 4
# 24 "/usr/include/sys/types.h" 3 4
typedef short int __int16_t;
typedef unsigned short int __uint16_t;





typedef int __int32_t;
typedef unsigned int __uint32_t;






__extension__ typedef long long __int64_t;
__extension__ typedef unsigned long long __uint64_t;
# 55 "/usr/include/sys/types.h" 3 4
# 1 "/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include/stddef.h" 1 3 4
# 158 "/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include/stddef.h" 3 4
typedef int ptrdiff_t;
# 332 "/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include/stddef.h" 3 4
typedef short unsigned int wchar_t;
# 56 "/usr/include/sys/types.h" 2 3 4
# 1 "/usr/include/machine/types.h" 1 3 4
# 36 "/usr/include/machine/types.h" 3 4
typedef long int __off_t;
typedef int __pid_t;

__extension__ typedef long long int __loff_t;
# 57 "/usr/include/sys/types.h" 2 3 4
# 78 "/usr/include/sys/types.h" 3 4
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;



typedef unsigned short ushort;
typedef unsigned int uint;



typedef unsigned long clock_t;




typedef long time_t;




struct timespec {
  time_t tv_sec;
  long tv_nsec;
};

struct itimerspec {
  struct timespec it_interval;
  struct timespec it_value;
};


typedef long daddr_t;
typedef char * caddr_t;
# 166 "/usr/include/sys/types.h" 3 4
typedef int pid_t;



typedef _ssize_t ssize_t;
# 189 "/usr/include/sys/types.h" 3 4
typedef unsigned short nlink_t;
# 211 "/usr/include/sys/types.h" 3 4
typedef long fd_mask;







typedef struct _types_fd_set {
        fd_mask fds_bits[(((64)+(((sizeof (fd_mask) * 8))-1))/((sizeof
(fd_mask) * 8)))];
} _types_fd_set;
# 247 "/usr/include/sys/types.h" 3 4
typedef unsigned long clockid_t;




typedef unsigned long timer_t;




typedef long useconds_t;


# 1 "/usr/include/sys/features.h" 1 3 4
# 261 "/usr/include/sys/types.h" 2 3 4
# 365 "/usr/include/sys/types.h" 3 4
# 1 "/usr/include/cygwin/types.h" 1 3 4
# 20 "/usr/include/cygwin/types.h" 3 4
# 1 "/usr/include/sys/sysmacros.h" 1 3 4
# 21 "/usr/include/cygwin/types.h" 2 3 4
# 1 "/usr/include/stdint.h" 1 3 4
# 18 "/usr/include/stdint.h" 3 4
typedef signed char int8_t;
typedef short int16_t;
typedef long int32_t;
typedef long long int64_t;


typedef unsigned char uint8_t;
typedef unsigned short uint16_t;


typedef unsigned long uint32_t;

typedef unsigned long long uint64_t;



typedef signed char int_least8_t;
typedef short int_least16_t;
typedef long int_least32_t;
typedef long long int_least64_t;

typedef unsigned char uint_least8_t;
typedef unsigned short uint_least16_t;
typedef unsigned long uint_least32_t;
typedef unsigned long long uint_least64_t;



typedef signed char int_fast8_t;
typedef long int_fast16_t;
typedef long int_fast32_t;
typedef long long int_fast64_t;

typedef unsigned char uint_fast8_t;
typedef unsigned long uint_fast16_t;
typedef unsigned long uint_fast32_t;
typedef unsigned long long uint_fast64_t;





typedef long intptr_t;

typedef unsigned long uintptr_t;



typedef long long intmax_t;
typedef unsigned long long uintmax_t;
# 22 "/usr/include/cygwin/types.h" 2 3 4



typedef struct timespec timespec_t;




typedef struct timespec timestruc_t;





typedef _off64_t off_t;







typedef short __dev16_t;
typedef unsigned long __dev32_t;

typedef __dev32_t dev_t;







typedef long blksize_t;




typedef long __blkcnt32_t;
typedef long long __blkcnt64_t;

typedef __blkcnt64_t blkcnt_t;







typedef unsigned short __uid16_t;
typedef unsigned long __uid32_t;

typedef __uid32_t uid_t;







typedef unsigned short __gid16_t;
typedef unsigned long __gid32_t;

typedef __gid32_t gid_t;







typedef unsigned long __ino32_t;
typedef unsigned long long __ino64_t;

typedef __ino64_t ino_t;
# 121 "/usr/include/cygwin/types.h" 3 4
struct flock {
        short l_type;
        short l_whence;
        off_t l_start;
        off_t l_len;

        pid_t l_pid;




};



typedef long long key_t;







typedef unsigned long vm_offset_t;




typedef unsigned long vm_size_t;




typedef void *vm_object_t;




typedef unsigned char u_int8_t;



typedef __uint16_t u_int16_t;



typedef __uint32_t u_int32_t;



typedef __uint64_t u_int64_t;




typedef __int32_t register_t;




typedef char *addr_t;




typedef unsigned mode_t;





typedef struct __pthread_t {char __dummy;} *pthread_t;
typedef struct __pthread_mutex_t {char __dummy;} *pthread_mutex_t;

typedef struct __pthread_key_t {char __dummy;} *pthread_key_t;
typedef struct __pthread_attr_t {char __dummy;} *pthread_attr_t;
typedef struct __pthread_mutexattr_t {char __dummy;} *pthread_mutexattr_t;
typedef struct __pthread_condattr_t {char __dummy;} *pthread_condattr_t;
typedef struct __pthread_cond_t {char __dummy;} *pthread_cond_t;


typedef struct
{
  pthread_mutex_t mutex;
  int state;
}
pthread_once_t;
typedef struct __pthread_rwlock_t {char __dummy;} *pthread_rwlock_t;
typedef struct __pthread_rwlockattr_t {char __dummy;} *pthread_rwlockattr_t;
# 366 "/usr/include/sys/types.h" 2 3 4
# 47 "/usr/include/stdio.h" 2 3 4



typedef __FILE FILE;



typedef _fpos64_t fpos_t;
# 65 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/sys/stdio.h" 1 3 4
# 14 "/usr/include/sys/stdio.h" 3 4
# 1 "/usr/include/sys/lock.h" 1 3 4
# 14 "/usr/include/sys/lock.h" 3 4
typedef void *_LOCK_T;
# 44 "/usr/include/sys/lock.h" 3 4
void __cygwin_lock_init(_LOCK_T *);
void __cygwin_lock_init_recursive(_LOCK_T *);
void __cygwin_lock_fini(_LOCK_T *);
void __cygwin_lock_lock(_LOCK_T *);
int __cygwin_lock_trylock(_LOCK_T *);
void __cygwin_lock_unlock(_LOCK_T *);
# 15 "/usr/include/sys/stdio.h" 2 3 4
# 66 "/usr/include/stdio.h" 2 3 4
# 170 "/usr/include/stdio.h" 3 4
FILE * __attribute__((__cdecl__)) tmpfile (void);
char * __attribute__((__cdecl__)) tmpnam (char *);
int __attribute__((__cdecl__)) fclose (FILE *);
int __attribute__((__cdecl__)) fflush (FILE *);
FILE * __attribute__((__cdecl__)) freopen (const char *, const char *, FILE
*);
void __attribute__((__cdecl__)) setbuf (FILE *, char *);
int __attribute__((__cdecl__)) setvbuf (FILE *, char *, int, size_t);
int __attribute__((__cdecl__)) fprintf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) fscanf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) printf (const char *, ...);
int __attribute__((__cdecl__)) scanf (const char *, ...);
int __attribute__((__cdecl__)) sscanf (const char *, const char *, ...);
int __attribute__((__cdecl__)) vfprintf (FILE *, const char *,
__gnuc_va_list);
int __attribute__((__cdecl__)) vprintf (const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vsprintf (char *, const char *,
__gnuc_va_list);
int __attribute__((__cdecl__)) fgetc (FILE *);
char * __attribute__((__cdecl__)) fgets (char *, int, FILE *);
int __attribute__((__cdecl__)) fputc (int, FILE *);
int __attribute__((__cdecl__)) fputs (const char *, FILE *);
int __attribute__((__cdecl__)) getc (FILE *);
int __attribute__((__cdecl__)) getchar (void);
char * __attribute__((__cdecl__)) gets (char *);
int __attribute__((__cdecl__)) putc (int, FILE *);
int __attribute__((__cdecl__)) putchar (int);
int __attribute__((__cdecl__)) puts (const char *);
int __attribute__((__cdecl__)) ungetc (int, FILE *);
size_t __attribute__((__cdecl__)) fread (void *, size_t _size, size_t _n,
FILE *);
size_t __attribute__((__cdecl__)) fwrite (const void * , size_t _size,
size_t _n, FILE *);



int __attribute__((__cdecl__)) fgetpos (FILE *, fpos_t *);

int __attribute__((__cdecl__)) fseek (FILE *, long, int);



int __attribute__((__cdecl__)) fsetpos (FILE *, const fpos_t *);

long __attribute__((__cdecl__)) ftell ( FILE *);
void __attribute__((__cdecl__)) rewind (FILE *);
void __attribute__((__cdecl__)) clearerr (FILE *);
int __attribute__((__cdecl__)) feof (FILE *);
int __attribute__((__cdecl__)) ferror (FILE *);
void __attribute__((__cdecl__)) perror (const char *);

FILE * __attribute__((__cdecl__)) fopen (const char *_name, const char
*_type);
int __attribute__((__cdecl__)) sprintf (char *, const char *, ...);
int __attribute__((__cdecl__)) remove (const char *);
int __attribute__((__cdecl__)) rename (const char *, const char *);
# 274 "/usr/include/stdio.h" 3 4
int __attribute__((__cdecl__)) _asprintf_r (struct _reent *, char **, const
char *, ...);
int __attribute__((__cdecl__)) _fcloseall_r (struct _reent *);
FILE * __attribute__((__cdecl__)) _fdopen_r (struct _reent *, int, const
char *);
FILE * __attribute__((__cdecl__)) _fopen_r (struct _reent *, const char *,
const char *);
int __attribute__((__cdecl__)) _fclose_r (struct _reent *, FILE *);
int __attribute__((__cdecl__)) _fscanf_r (struct _reent *, FILE *, const
char *, ...);
int __attribute__((__cdecl__)) _fseek_r (struct _reent *, FILE *, long,
int);
long __attribute__((__cdecl__)) _ftell_r (struct _reent *, FILE *);
int __attribute__((__cdecl__)) _getchar_r (struct _reent *);
char * __attribute__((__cdecl__)) _gets_r (struct _reent *, char *);
int __attribute__((__cdecl__)) _iprintf_r (struct _reent *, const char *,
...);
int __attribute__((__cdecl__)) _siprintf_r (struct _reent *, char *, const
char *, ...);
int __attribute__((__cdecl__)) _mkstemp_r (struct _reent *, char *);
char * __attribute__((__cdecl__)) _mktemp_r (struct _reent *, char *);
void __attribute__((__cdecl__)) _perror_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _printf_r (struct _reent *, const char *,
...);
int __attribute__((__cdecl__)) _putchar_r (struct _reent *, int);
int __attribute__((__cdecl__)) _puts_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _remove_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _rename_r (struct _reent *, const char *_old,
const char *_new);

int __attribute__((__cdecl__)) _scanf_r (struct _reent *, const char *,
...);
int __attribute__((__cdecl__)) _sprintf_r (struct _reent *, char *, const
char *, ...);
int __attribute__((__cdecl__)) _snprintf_r (struct _reent *, char *, size_t,
const char *, ...);
int __attribute__((__cdecl__)) _sscanf_r (struct _reent *, const char *,
const char *, ...);
char * __attribute__((__cdecl__)) _tempnam_r (struct _reent *, const char *,
const char *);
FILE * __attribute__((__cdecl__)) _tmpfile_r (struct _reent *);
char * __attribute__((__cdecl__)) _tmpnam_r (struct _reent *, char *);
int __attribute__((__cdecl__)) _ungetc_r (struct _reent *, int, FILE *);
int __attribute__((__cdecl__)) _vasprintf_r (struct _reent *, char **, const
char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vfiprintf_r (struct _reent *, FILE *, const
char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vfprintf_r (struct _reent *, FILE *, const
char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vprintf_r (struct _reent *, const char *,
__gnuc_va_list);
int __attribute__((__cdecl__)) _vsprintf_r (struct _reent *, char *, const
char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vsnprintf_r (struct _reent *, char *,
size_t, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vfscanf_r (struct _reent *, FILE *, const
char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vscanf_r (struct _reent *, const char *,
__gnuc_va_list);
int __attribute__((__cdecl__)) _vsscanf_r (struct _reent *, const char *,
const char *, __gnuc_va_list);

ssize_t __attribute__((__cdecl__)) __getdelim (char **, size_t *, int, FILE
*);
ssize_t __attribute__((__cdecl__)) __getline (char **, size_t *, FILE *);
# 340 "/usr/include/stdio.h" 3 4
int __attribute__((__cdecl__)) __srget (FILE *);
int __attribute__((__cdecl__)) __swbuf (int, FILE *);
# 365 "/usr/include/stdio.h" 3 4
static __inline__ int __sgetc(FILE *__p)
  {
    int __c = (--(__p)->_r < 0 ? __srget(__p) : (int)(*(__p)->_p++));
    if ((__p->_flags & 0x4000) && (__c == '\r'))
      {
      int __c2 = (--(__p)->_r < 0 ? __srget(__p) : (int)(*(__p)->_p++));
      if (__c2 == '\n')
        __c = __c2;
      else
        ungetc(__c2, __p);
      }
    return __c;
  }
# 447 "/usr/include/stdio.h" 3 4

# 2 "do_it.c" 2

void do_it (int *restrict foo, int *restrict bar);

void do_it (int *restrict foo, int *restrict bar)
{
  printf ("foo = %d, bar = %d", *foo, *bar);
}
--source ends--
--gcc -v output begins--
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with:
/GCC/gcc-3.3.1-3/configure --with-gcc --with-gnu-ld --with-gnu-
as --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --li
bexe
cdir=/usr/sbin --mandir=/usr/share/man --infodir=/usr/share/info --enable-la
ngua
ges=c,ada,c++,f77,pascal,java,objc --enable-libgcj --enable-threads=posix --
with
-system-zlib --enable-nls --without-included-gettext --enable-interpreter --
enab
le-sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared -
-dis
able-win32-registry --enable-java-gc=boehm --disable-hash-synchronization --
verb
ose --target=i686-pc-cygwin --host=i686-pc-cygwin --build=i686-pc-cygwin
Thread model: posix
gcc version 3.3.1 (cygming special)
--gcc -v output ends--



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

* Re: Bug in restricted pointers (C99)?
  2004-06-07  0:32 Bug in restricted pointers (C99)? The Thodes
@ 2004-06-08 19:00 ` Jim Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Wilson @ 2004-06-08 19:00 UTC (permalink / raw)
  To: The Thodes; +Cc: gcc-bugs

The Thodes wrote:
> GCC 3.3.1 on i686-pc-cygwin does not squawk if I try to pass the same
> address twice to a fn taking two restrict-qualified ptrs as args... (src,
> output follows)

This is a programmer bug, not a compiler bug.  The ISO C99 standard says 
that the behaviour of the program is undefined.  There is no requirement 
for the compiler to emit a diagnostic here.  It is the programmer's 
responsibility to use restrict correctly, and there is no requirement 
for the compiler to do any checking of it.

In general, it is not possible for a compiler to determine when there 
are problems with uses of the restrict keyword.  Doing this would 
require perfect interprocedural aliasing analysis, and that is difficult 
to impossible.  Thus the compiler is not required to emit any warnings, 
even in obvious cases like this.  If we did have perfect aliasing info, 
then we wouldn't need the restrict keyword.  The restrict keyword exists 
as an optimization, because compilers can't determine this info themselves.

We could perhaps emit a warning in an obvious case like this as an 
enhancement.  We will never be able to warn for all incorrect uses though.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com


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

end of thread, other threads:[~2004-06-08 19:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-07  0:32 Bug in restricted pointers (C99)? The Thodes
2004-06-08 19:00 ` Jim Wilson

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