www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - [bug?] compiler option -a4 causes abnormal program termination on

↑ ↓ ← Anton Sekeris <no.spam inter.nl.net> writes:
Walter,

A bit of my code recently started causing grief. The minimum 
reproduction I eventually whittled it down to looks like this:

	#include <sstream>

	void f() {
	  std::stringstream str;
	}

	#include <iostream>
	
	int main () {
	  return 0;
	}

If you compile this with 'dmc test.cpp', all is well. Compile it with 
'dmc test.cpp -a4' and you get abnormal program terminations. The 
additional plethora of command line options I normally have make no 
difference, the alignment option is the culprit it seems.

I hadn't compiled this code a while and am not sure when it last worked 
(or even if the -a4 was recently added in my makefiles), but I am 
currently updated to the latest beta (8.49).

I don't particularly require struct alignment, so for me its just 
removing -a4 and I'm okay for now.

Kind regards,
Anton Sekeris.
Jun 02 2006
↑ ↓ Walter Bright <newshound digitalmars.com> writes:
Anton Sekeris wrote:
 Walter,
 
 A bit of my code recently started causing grief. The minimum 
 reproduction I eventually whittled it down to looks like this:
 
     #include <sstream>
 
     void f() {
       std::stringstream str;
     }
 
     #include <iostream>
     
     int main () {
       return 0;
     }
 
 If you compile this with 'dmc test.cpp', all is well. Compile it with 
 'dmc test.cpp -a4' and you get abnormal program terminations. The 
 additional plethora of command line options I normally have make no 
 difference, the alignment option is the culprit it seems.
 
 I hadn't compiled this code a while and am not sure when it last worked 
 (or even if the -a4 was recently added in my makefiles), but I am 
 currently updated to the latest beta (8.49).
 
 I don't particularly require struct alignment, so for me its just 
 removing -a4 and I'm okay for now.

What is likely happening is you're linking with iostream, which is compiled with default alignment. Compiling the app with -a4 will cause the class members to not line up with the object code in the library. Generally, it's a very bad idea to use the -a switch. Use the #pragma align around individual structs that need special alignment.
Jun 02 2006
↑ ↓ Anton Sekeris <no.spam inter.nl.net> writes:
Walter Bright wrote:
 Anton Sekeris wrote:
 Walter,

 A bit of my code recently started causing grief. The minimum 
 reproduction I eventually whittled it down to looks like this:

     #include <sstream>

     void f() {
       std::stringstream str;
     }

     #include <iostream>
         int main () {
       return 0;
     }

 If you compile this with 'dmc test.cpp', all is well. Compile it with 
 'dmc test.cpp -a4' and you get abnormal program terminations. The 
 additional plethora of command line options I normally have make no 
 difference, the alignment option is the culprit it seems.

 I hadn't compiled this code a while and am not sure when it last 
 worked (or even if the -a4 was recently added in my makefiles), but I 
 am currently updated to the latest beta (8.49).

 I don't particularly require struct alignment, so for me its just 
 removing -a4 and I'm okay for now.

What is likely happening is you're linking with iostream, which is compiled with default alignment. Compiling the app with -a4 will cause the class members to not line up with the object code in the library. Generally, it's a very bad idea to use the -a switch. Use the #pragma align around individual structs that need special alignment.

Noted, the -a switch is out the window here, thanks. I figured out where something went wrong though. Some of our makefiles were generated by ultraedit/uemake. We recently switched to uestudio. Both applications support sc/dmc, which is cool. It seems uestudio by defaults adds a -a directive to the makefiles. I'll let the author of that program know that he may need to do something with this.
Jun 03 2006
↑ ↓ → Walter Bright <newshound digitalmars.com> writes:
Anton Sekeris wrote:
 Noted, the -a switch is out the window here, thanks. I figured out where 
 something went wrong though. Some of our makefiles were generated by 
 ultraedit/uemake. We recently switched to uestudio. Both applications 
 support sc/dmc, which is cool. It seems uestudio by defaults adds a -a 
 directive to the makefiles. I'll let the author of that program know 
 that he may need to do something with this.

It is common for makefiles to include lots of switches for which the reason they are there has been lost or is no longer relevant. They accumulate like rust <g>.
Jun 03 2006