#324 Eigen compilation fails in headers (only with -O)

closed-fixed
nobody
header (101)
5
2012-11-05
2012-11-05
Anonymous
No

WIth both TDM (tdm64-1, 4.7.1) and rubenvb-4.7.2-release, the eigen header-only library (http://eigentuxfamily.org) fails in system header if compiled, but only with optimizations enabled (via -O). Exact error message is poste below, it is the same (including line number, as I checked briefly) between the TDM and the rubenvb build. Compilation without -O works just fine.

There are two groups of errors (both can be avoided by commenting out offending declarations):

1. in MinGW64\x86_64_w64-mingw32\include\stdlib.h, lines 626-628: functions wtoll, lltow, ulltow use undeclared _wtoi64, _i64tow. This error is triggered by compiling <Eigen/Core> proper.

2. in MinGW64\x86_64_w64-mingw32\include\sys\stat.h, 64-bit related structs are reported as undefined. This error is triggered by #include<sys/stat.h> _after_ <Eigen/Core>.

It is possible that this is a bug in Eigen, but I am not sure. In any case, people here will be able to point out more quickly where the problem comes from.

===

Steps to reproduce (with MSYS):

wget --no-check-certificate http://bitbucket.org/eigen/eigen/get/3.1.1.tar.gz
cd eigen-eigen-43d9075b23ef

$ echo -e "#include<Eigen/Core>\n#include<sys/stat.h>" | g++ -c -x c++ -I. -
$ echo $?
0
$ echo -e "#include<Eigen/Core>\n#include<sys/stat.h>" | g++ -c -x c++ -O -I. -
In file included from c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/include/mm_malloc.h:27:0,
from c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/include/xmmintrin.h:39,
from c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/include/emmintrin.h:36,
from ./Eigen/Core:90,
from <stdin>:1:
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stdlib.h: In function 'long long int wtoll(const wchar_t*)':
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stdlib.h:626:100: error: '_wtoi64' was not declared in this scope
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stdlib.h: In function 'wchar_t* lltow(long long int, wchar_t*, int)':
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stdlib.h:627:122: error: '_i64tow' was not declared in this scope
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stdlib.h: In function 'wchar_t* ulltow(long long unsigned int, wchar_t*, int)':
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stdlib.h:628:133: error: '_ui64tow' was not declared in this scope
In file included from <stdin>:2:0:
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h: In function 'int _fstat64i32(int, _stat64i32*)':
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:77:20: error: aggregate '_stat64 st' has incomplete type and cannot be defined
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:80:46: error: invalid application of 'sizeof' to incomplete type '_stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:83:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:84:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:85:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:86:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:87:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:88:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:89:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:90:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:91:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:92:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:93:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h: In function 'int _stat64i32(const char*, _stat64i32*)':
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:103:20: error: aggregate '_stat64 st' has incomplete type and cannot be defined
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:106:46: error: invalid application of 'sizeof' to incomplete type '_stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:109:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:110:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:111:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:112:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:113:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:114:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:115:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:116:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:117:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:118:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:119:10: error: invalid use of incomplete type 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:73:47: error: forward declaration of 'struct _stat64i32'
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h: In function 'int fstat(int, stat*)':
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/sys/stat.h:202:18: error: aggregate '_stat64 st' has incomplete type and cannot be defined

Discussion

  • Jonathan Yong
    Jonathan Yong
    2012-11-05

    Works for me, at least with:
    /bin/echo -e '#include<mm_malloc.h>\n#include<sys/stat.h>' | x86_64-w64-mingw32-gcc -xc++ - -c -o 1.o -O

    /bin/echo -e '#include<emmintrin.h>\n#include<sys/stat.h>' | x86_64-w64-mingw32-gcc -xc++ - -c -o 1.o -O0

    /bin/echo -e '#include<emmintrin.h>\n#include<sys/stat.h>' | x86_64-w64-mingw32-gcc -xc++ - -c -o 1.o -O

    Eigen needs som poking, didn't look like a mingw-w64 issue.

     
  • Jonathan Yong
    Jonathan Yong
    2012-11-05

    • status: open --> open-works-for-me
     
  • Jonathan Yong
    Jonathan Yong
    2012-11-05

    Nope, tested with Eigen too, can't reproduce. Using trunk headers and CRT with gcc trunk 4.8.

    /bin/echo -e '#include<Eigen/Core>\n#include<sys/stat.h>' | x86_64-w64-mingw32-gcc -xc++ - -c -o 1.o -O0 -I.

    /bin/echo -e '#include<Eigen/Core>\n#include<sys/stat.h>' | x86_64-w64-mingw32-gcc -xc++ - -c -o 1.o -O -I.

     

  • Anonymous
    2012-11-05

    I raised this at Eigen side at http://eigen.tuxfamily.org/bz/show_bug.cgi?id=528.

    I also confirm that

    #include<stdlib>
    #include<sys/stat.h>
    #include<Eigen/Core>

    with gcc 4.7.1 & 4.7.2.

    Since jon_y says it is ok with 4.8, I will close this as Fixed (feel free to change if that is not OK).

     
    Last edit: Anonymous 2014-03-16

  • Anonymous
    2012-11-05

    • status: open-works-for-me --> closed-fixed