c++ - [bug?] compiler option -a4 causes abnormal program termination on
- Anton Sekeris (23/23) Jun 02 2006 Walter,
- Walter Bright (6/34) Jun 02 2006 What is likely happening is you're linking with iostream, which is
- Anton Sekeris (7/42) Jun 03 2006 Noted, the -a switch is out the window here, thanks. I figured out where...
- Walter Bright (4/10) Jun 03 2006 It is common for makefiles to include lots of switches for which the
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
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
Walter Bright wrote: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.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 03 2006
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