Amazing VC++ bug 
Author Message
 Amazing VC++ bug

I was debugging part of the code generator for the PLI compiler.

There is a typedef in one of my headers:

typedef enum regs_e
{
AL=1,
AX,
EAX,
CL,
CX,
ECX,
DL,
DX,
EDX,
BL,
BX,
EBX,
AH,
SP,
ESP,
CH,
BP,
EBP,
DH,
SI,
ESI,
BH,
DI,
EDI

Quote:
} Reg;

To my astonishment, after much debugging, I discovered that these enum names are NOT what one would expect at runtime.

They are in fact names that refer to the real registers in the CPU!!!

Their values are whatever is in the register at the time, this led to amazingly complex and bad behaviour.

No only were they different values, but they vary as the code runs, for example:

inst.source.base = EBX;

was setting inst.source.base to 1023356 but when I looked art EBX it was 1100089.

Clearly the register value was changing as the assigmnet itself was executed.

This is one of the worst bugs I have ever seen in 20 years!!!

Hugh Gleaves
Philadelphia
USA



Tue, 29 Mar 2005 08:49:56 GMT  
 Amazing VC++ bug
Interesting that you deem it necessary to write a compiler for PL/I  using
another language (VC++)
whereas I found fortran's character string handling ideal for my C2F
translator program which is nothing more than efficient handling of
substrings, comparisons, shuffling, in converting the C source to Fortran..


Tue, 29 Mar 2005 19:33:18 GMT  
 Amazing VC++ bug

Quote:

> I was debugging part of the code generator for the PLI compiler.

> There is a typedef in one of my headers:

Visual C++ doesn't provide for user 'register variable'
declarations... this is done because its optimizer wants
to use registers in its own inimitable fashion.

Try disabling all optimization, and while the header\
will still likely be included, you may observe different
behavior.

At any rate, this is likely a feature, and not a bug...

Of course, a feature is defined to be any bug with
sufficient seniorority (sp?)!

-dq



Tue, 29 Mar 2005 20:45:34 GMT  
 Amazing VC++ bug
heres a photo of david frank while posting to comp.lang.pl1

http://vatican.rotten.com/fecaljapan/

yummy, thanks dave

Quote:

> Interesting that you deem it necessary to write a compiler for PL/I  using
> another language (VC++)
> whereas I found Fortran's character string handling ideal for my C2F
> translator program which is nothing more than efficient handling of
> substrings, comparisons, shuffling, in converting the C source to Fortran..



Wed, 30 Mar 2005 09:51:29 GMT  
 Amazing VC++ bug

Hi

I dont quite follow you Doug.

My typedef enum is just a local typedef, its an ordinary enum and the names I created to represent registers are quite
legal.

However at runtime, these names (which would ordinarily be simple int constants) actually take on the value of the
actual registers!

These names should only be associated with registers inside a __asm block, well thats what I think.

It looks like a real bug, nobody (except an assembler programmer) expects constants to map to registers.

Interestinlgy if define these constants using #define then all is well, very strange.

The original DOS code gen did exactly this, used #define so the prob never arose.

Anyway I renamed them all so they have a leading _ char and all is well now.

Thanks


Quote:

>> I was debugging part of the code generator for the PLI compiler.

>> There is a typedef in one of my headers:

>Visual C++ doesn't provide for user 'register variable'
>declarations... this is done because its optimizer wants
>to use registers in its own inimitable fashion.

>Try disabling all optimization, and while the header\
>will still likely be included, you may observe different
>behavior.

>At any rate, this is likely a feature, and not a bug...

>Of course, a feature is defined to be any bug with
>sufficient seniorority (sp?)!

>-dq

Hugh Gleaves
Philadelphia
USA


Wed, 30 Mar 2005 12:39:08 GMT  
 Amazing VC++ bug



Quote:
> heres a photo of david frank while posting to comp.lang.pl1

> http://vatican.rotten.com/fecaljapan/

> yummy, thanks dave

Dear Boring  (for 17 years now)...
I see you cropped out the right side of the photo where it shows you with
your mouth open, yummy'ing down the crap..


Wed, 30 Mar 2005 14:50:34 GMT  
 Amazing VC++ bug

Quote:

> These names should only be associated with registers inside a __asm block, well thats what I think.

> It looks like a real bug, nobody (except an assembler programmer)
> expects constants to map to registers.

And there you have it. In terms of lines of code, I've
written more in assembly language than in anything else,
even <shudder> BASIC.

Some habits are hard to break...

-dq



Thu, 31 Mar 2005 22:29:06 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. amazing bug in tclsh8.5?

2. RC1 VC bug

3. funny VC++ version 4 YR2K bug

4. BUG in makefile.vc, tk 8.4a3

5. tk4.1b3 bug?? (compiled with VC)

6. vc++ and clipper indexed files of dbf

7. how to call one vc++ dll inLabview?

8. Setting up vc++ to work with effiel

9. I can't execute int 10h in vc++

10. how to call a c++ constructor in vc++ inline assembly

11. using vc++ function in asm

12. configuring vc++ ide for compile with masm

 

 
Powered by phpBB® Forum Software