|
Archives
D Programming
DD.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++ - code generation bug?
My first day using dmc. I fed it some C++ code that was known to be
well-behaved; the resulting .exe crashed. I couldn't get the assembler listing
working, but I was able to move code and get the correct behaviour.
The crashing code:
switch (p->cmd) //dies around here
{
case CMD_Set:
setpins(p->pinset, p->set.onV);
return 0;
case CMD_SetFreq:
for (i = 0; i < 5; ++i)
..etc
The working code, which is equivalent:
//DigitalMars compiler generates a jump to address 0
//if this is a case in the switch
//no problem as an If, though.
#if 01
if (p->cmd == CMD_Set)
{
setpins(p->pinset, p->set.onV);
return 0;
}
#endif
switch (p->cmd)
{
case CMD_Set:
setpins(p->pinset, p->set.onV);
return 0;
case CMD_SetFreq:
for (i = 0; i < 5; ++i)
I'm new here - does anyone do support? I can make the source available; the
compile command line was just
dmc mycode.cpp
The code uses no explicit new/delete/malloc/stl/iostreams/overloading or any
interesting trickery. There is some inline asembler, but when I compile and run
it as a console app using the microsoft IDE, that same assmbler runs just fine,
so I don't think it's doing any damage. Really looks like a compiler issue to
me. Help?
Another trick that worked, then the code was part of the switch statement, was
to put a fprintf in the case.
Mar 17 2006
Hello, Scott Mayo wrote... Mar 20 2006
Mybe an uninitialized pointer p? What makes me think it's this kind of error is that your code works when adding the extra statements. Mar 20 2006
|