Hello, There seems to be a bug in cygwin linker, which causes invalid order of object initialization. Comments?
rgds, PRR --- bug.cpp: #include <stdio.h> class CIntHolder{ public: CIntHolder(int iValue) { m_iValue=iValue; } int m_iValue; }; static int g_Counter; CIntHolder g_Object3(++g_Counter); CIntHolder __attribute__ ((init_priority(102))) g_Object2(++g_Counter); CIntHolder __attribute__ ((init_priority(101))) g_Object1(++g_Counter); CIntHolder g_Object4(++g_Counter); int main(){ printf("%d %d %d %d\n", g_Object1.m_iValue, g_Object2.m_iValue, g_Object3.m_iValue, g_Object4.m_iValue); return 0; } --- According to documentation, default objects have lowest priority (0xffff), so the correct order of g_Object initalization should be 1, 2, 3, 4. Programs compiled under CygWin create Objects 3 and 4 prior to 1 and 2. --- Possible cause: Objects, that have init_priority defined, are created in correct order, which implies that the default priority of object initialization is etiher 0 or not initialized on linker startup. --- Screenshot: prr@PRR / $ g++ bug.cpp prr@PRR / $ ./a.exe 3 4 1 2 prr@PRR / $ gcc -v Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.2/specs Configured with: /netrel/src/gcc-3.2-3/configure --enable-languages=c,c++,f77,ja va --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --with out-included-gettext --enable-interpreter --disable-sjlj-exceptions --disable-ve rsion-specific-runtime-libs --enable-shared --build=i686-pc-linux --host=i686-pc -cygwin --target=i686-pc-cygwin --enable-haifa --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --includedir=/nonexistent/include --libexecd ir=/usr/sbin Thread model: posix gcc version 3.2 20020927 (prerelease) prr@PRR / $ ld -v GNU ld version 2.13.90 20021118 --- cygcheck.out: Cygwin Win95/NT Configuration Diagnostics Current System Time: Mon Jan 20 14:46:09 2003 Windows 2000 Professional Ver 5.0 Build 2195 Service Pack 2 Path: C:\cygwin\usr\local\bin C:\cygwin\bin C:\cygwin\bin c:\WINNT\system32 c:\WINNT c:\WINNT\System32\Wbem c:\Program Files\ATI Technologies\ATI Control Panel c:\Program Files\Symantec\pcAnywhere\ SysDir: C:\WINNT\System32 WinDir: C:\WINNT HOME = :\cygwin' MAKE_MODE = nix' PWD = /' USER = rr' ALLUSERSPROFILE = :\Documents and Settings\All Users' APPDATA = :\Documents and Settings\prr\Application Data' COMMONPROGRAMFILES = :\Program Files\Common Files' COMPUTERNAME = RR' COMSPEC = :\WINNT\system32\cmd.exe' HOMEDRIVE = :' HOMEPATH = ' LOGONSERVER = \FSERVER' NUMBER_OF_PROCESSORS = OLDPWD = /usr/bin' OS2LIBPATH = :\WINNT\system32\os2\dll;' OS = indows_NT' PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH' PROCESSOR_ARCHITECTURE = †' PROCESSOR_IDENTIFIER = † Family 15 Model 2 Stepping 4, GenuineIntel' PROCESSOR_LEVEL = PROCESSOR_REVISION = 4' PROGRAMFILES = :\Program Files' PROMPT = $P$G' PS1 = [\033]0;\w\007 \033[32m\]\u@\h \[\033[33m\w\033[0m\] $ ' SHLVL = SYSTEMDRIVE = :' SYSTEMROOT = :\WINNT' TEMP = :\DOCUME~1\prr\LOCALS~1\Temp' TERM = ygwin' TMP = :\DOCUME~1\prr\LOCALS~1\Temp' USERDNSDOMAIN = laytech.playtech' USERDOMAIN = LAYTECH' USERNAME = rr' USERPROFILE = :\Documents and Settings\prr' WINDIR = :\WINNT' _ = /usr/bin/cygcheck' HKEY_CURRENT_USER\Software\Cygnus Solutions HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 (default) = /cygdrive' cygdrive flags = 0x00000022 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/ (default) = :\cygwin' flags = 0x0000000a HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin (default) = :\cygwin/bin' flags = 0x0000000a HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib (default) = :\cygwin/lib' flags = 0x0000000a HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options a: fd N/A N/A c: hd NTFS 10001Mb 82% CP CS UN PA FC d: hd NTFS 26999Mb 59% CP CS UN PA FC Work e: hd NTFS 2196Mb 65% CP CS UN PA FC Personal f: cd CDFS 0Mb -2147483548% CS Audio CD h: net NTFS 60000Mb 8% CP CS UN PA FC Develop k: net NTFS 20002Mb 22% CP CS UN PA FC Clients t: net NTFS 259408Mb 77% CP CS UN PA Graphics C:\cygwin / system binmode C:\cygwin/bin /usr/bin system binmode C:\cygwin/lib /usr/lib system binmode . /cygdrive user binmode,cygdrive Found: C:\cygwin\bin\bash.exe Found: C:\cygwin\bin\cat.exe Found: C:\cygwin\bin\cpp.exe Found: C:\cygwin\bin\find.exe Found: C:\cygwin\bin\gcc.exe Not Found: gdb Found: C:\cygwin\bin\ld.exe Found: C:\cygwin\bin\ls.exe Not Found: make Found: C:\cygwin\bin\sh.exe 45k 2001/04/25 C:\cygwin\bin\cygform5.dll - os=4.0 img=1.0 sys=4.0 "cygform5.dll" v0.0 ts=2001/4/25 8:28 35k 2002/01/09 C:\cygwin\bin\cygform6.dll - os=4.0 img=1.0 sys=4.0 "cygform6.dll" v0.0 ts=2002/1/9 8:03 19k 2002/02/20 C:\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm.dll" v0.0 ts=2002/2/20 5:05 17k 2001/06/28 C:\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0 "cyghistory4.dll" v0.0 ts=2001/1/7 6:34 20k 2002/10/10 C:\cygwin\bin\cyghistory5.dll - os=4.0 img=1.0 sys=4.0 "cyghistory5.dll" v0.0 ts=2002/10/10 20:28 929k 2002/06/24 C:\cygwin\bin\cygiconv-2.dll - os=4.0 img=1.0 sys=4.0 "cygiconv-2.dll" v0.0 ts=2002/6/24 21:24 22k 2001/12/13 C:\cygwin\bin\cygintl-1.dll - os=4.0 img=1.0 sys=4.0 "cygintl-1.dll" v0.0 ts=2001/12/13 11:28 28k 2002/09/20 C:\cygwin\bin\cygintl-2.dll - os=4.0 img=1.0 sys=4.0 "cygintl-2.dll" v0.0 ts=2002/9/20 6:13 26k 2001/04/25 C:\cygwin\bin\cygmenu5.dll - os=4.0 img=1.0 sys=4.0 "cygmenu5.dll" v0.0 ts=2001/4/25 8:27 20k 2002/01/09 C:\cygwin\bin\cygmenu6.dll - os=4.0 img=1.0 sys=4.0 "cygmenu6.dll" v0.0 ts=2002/1/9 8:03 156k 2001/04/25 C:\cygwin\bin\cygncurses++5.dll - os=4.0 img=1.0 sys=4.0 "cygncurses++5.dll" v0.0 ts=2001/4/25 8:29 175k 2002/01/09 C:\cygwin\bin\cygncurses++6.dll - os=4.0 img=1.0 sys=4.0 "cygncurses++6.dll" v0.0 ts=2002/1/9 8:03 226k 2001/04/25 C:\cygwin\bin\cygncurses5.dll - os=4.0 img=1.0 sys=4.0 "cygncurses5.dll" v0.0 ts=2001/4/25 8:17 202k 2002/01/09 C:\cygwin\bin\cygncurses6.dll - os=4.0 img=1.0 sys=4.0 "cygncurses6.dll" v0.0 ts=2002/1/9 8:03 15k 2001/04/25 C:\cygwin\bin\cygpanel5.dll - os=4.0 img=1.0 sys=4.0 "cygpanel5.dll" v0.0 ts=2001/4/25 8:27 12k 2002/01/09 C:\cygwin\bin\cygpanel6.dll - os=4.0 img=1.0 sys=4.0 "cygpanel6.dll" v0.0 ts=2002/1/9 8:03 40k 2001/11/21 C:\cygwin\bin\cygpcre.dll - os=4.0 img=1.0 sys=4.0 "cygpcre.dll" v0.0 ts=2001/11/22 0:15 39k 2001/11/21 C:\cygwin\bin\cygpcreposix.dll - os=4.0 img=1.0 sys=4.0 "cygpcreposix.dll" v0.0 ts=2001/11/22 0:15 108k 2001/06/28 C:\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0 sys=4.0 "cygreadline4.dll" v0.0 ts=2001/1/7 6:34 127k 2002/10/10 C:\cygwin\bin\cygreadline5.dll - os=4.0 img=1.0 sys=4.0 "cygreadline5.dll" v0.0 ts=2002/10/10 20:28 50k 2002/03/12 C:\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0 "cygz.dll" v0.0 ts=2002/3/12 6:38 880k 2002/12/25 C:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0 "cygwin1.dll" v0.0 ts=2002/12/25 22:37 Cygwin DLL version info: DLL version: 1.3.18 DLL epoch: 19 DLL bad signal mask: 19005 DLL old termios: 5 DLL malloc env: 28 API major: 0 API minor: 69 Shared data: 3 DLL identifier: cygwin1 Mount registry: 2 Cygnus registry name: Cygnus Solutions Cygwin registry name: Cygwin Program options name: Program Options Cygwin mount registry name: mounts v2 Cygdrive flags: cygdrive flags Cygdrive prefix: cygdrive prefix Cygdrive default prefix: Build date: Wed Dec 25 15:37:50 EST 2002 Shared id: cygwin1S3 Cygwin Package Information Last downloaded files to: C:\temp\CygWin Last downloaded files from: ftp://ftp.inf.tu-dresden.de/software/windows/cygwin32 Package Version _update-info-dir 00121-1 ash 20020731-1 autoconf 2.54-1 autoconf-devel 2.57-1 autoconf-stable 2.13-4 automake 1.7.1-1 automake-devel 1.7.2-1 automake-stable 1.4p5-5 base-files 1.1-1 base-passwd 1.0-1 bash 2.05b-8 binutils 20021117-1 cmake 1.4.7-1 cygwin 1.3.18-1 diff 1.0-1 diffutils 2.8.1-1 fileutils 4.1-1 findutils 4.1.7-4 gawk 3.1.1-5 gcc 3.2-3 gcc-mingw 20020817-5 gdbm 1.8.0-4 grep 2.5-1 gzip 1.3.3-4 libiconv2 1.8-2 libintl1 0.10.40-1 libintl2 0.11.5-1 libncurses5 5.2-1 libncurses6 5.2-8 libreadline4 4.1-2 libreadline5 4.3-2 login 1.7-1 m4 1.4-1 mingw-runtime 2.3-1 mktemp 1.4-1 ncurses 5.2-8 pcre 3.7-1 perl 5.6.1-2 readline 4.3-2 sed 4.0.5-1 sh-utils 2.0.15-3 tar 1.13.25-1 termcap 20020930-1 terminfo 5.2-3 texinfo 4.2-4 textutils 2.0.21-1 w32api 2.1-1 which 1.5-1 zlib 1.1.4-1 Use -h to see help about each section -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/