#1323 stat produces incorrect result with w64-mingw under -O2

None
closed-invalid
nobody
None
2013-01-17
2009-07-31
No

This is a continuation of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40909

Test:
--- t.c ---
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>

int main(int argc, char *argv[])
{
struct stat st;
if (0 == stat(argv[0], &st))
printf("mode = %x\n", st.st_mode);
return 0;
}
--- t.c ---

Using x86_64-w64-mingw32-gcc (GCC) 4.5.0 20090726 (experimental)
from here:
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds/mingw-w64-bin_i686-cygwin-1.5.25-15_20090726.tar.bz2/download

/usr/local/mingw-w64/bin/x86_64-w64-mingw32-gcc -g t.c -O2 && ./a.exe
mode = 0

/usr/local/mingw-w64/bin/x86_64-w64-mingw32-gcc -g t.c -O0 && ./a.exe
mode = 81ff

/usr/local/mingw-w64/bin/x86_64-w64-mingw32-gcc -g t.c -O2 -fno-strict-aliasing && ./a.exe
mode = 81ff

According to GCC developers, this:
extern __inline__ int __attribute__((__cdecl__)) stat(const char *_Filename,struct stat *_Stat) {
return _stat64i32(_Filename,(struct _stat64i32 *)_Stat);
is an aliasing violation.

Discussion

  • Paul Pluzhnikov

    Paul Pluzhnikov - 2009-07-31

    From sezeroz at gmail dot com:

    Wrong project tracker. Please go to
    https://sourceforge.net/tracker/?group_id=202880 for the mingw-w64 tracker.
    BTW, I worked around the issue in our svn by adding optimize("0") attributes to
    those one-line inlines for now. Use revision 1108 and it'll be fine.

     
  • Earnie Boyd

    Earnie Boyd - 2009-07-31
    • labels: 456608 -->
    • milestone: --> 64_bit_feature_request
    • status: open --> closed-invalid
     

Log in to post a comment.