Error in VC 6.0 SP1 Compiler? 
Author Message
 Error in VC 6.0 SP1 Compiler?

What i want to type was this:

    int a = sizeof(int) + sizeof(double);

bat what i dit was this:

    int a = sizeof(int) sizeof(double);

Unfortunately there was no Compiler Error or Warning. Is there someone
who know this effect?

Arnold



Sun, 22 Apr 2001 03:00:00 GMT  
 Error in VC 6.0 SP1 Compiler?

Quote:
>    int a = sizeof(int) sizeof(double);

Interesting. The value assigned to a is the result of the leftmost
expression. Il you look at the assembly code, you'll see that the second
expression is merely ignored by the compiler:

    mov    dword ptr[ebp-4], 4

int a = 4 8; won't compile however but  int a = sizeof(int) 8; will compile.

The Borland compiler flags this syntax error in any case.

Patrick Philippot (MainSoft sarl)

http://ourworld.compuserve.com/homepages/mainsoft
tel/fax: +33 (0)1 69 40 94 85



Tue, 24 Apr 2001 03:00:00 GMT  
 Error in VC 6.0 SP1 Compiler?

Quote:

> What i want to type was this:

>     int a = sizeof(int) + sizeof(double);

> bat what i dit was this:

>     int a = sizeof(int) sizeof(double);

> Unfortunately there was no Compiler Error or Warning. Is there someone
> who know this effect?

> Arnold

Compiler interprets this like:
int a = sizeof((int)(sizeof(double)));

--
Rimantas Endriukaitis
=============================

=============================

  endriu.vcf
< 1K Download


Tue, 24 Apr 2001 03:00:00 GMT  
 Error in VC 6.0 SP1 Compiler?

Quote:

> Compiler interprets this like:
> int a = sizeof((int)(sizeof(double)));

Oh, bl**dy hell.  Of course it does.

M

--
   "It's the gaps between the rain that count,
     and learning how to live amongst them."
          -- Jeff Noon, _Pixel Juice_
Matt Gibson                          http://www.netgates.co.uk/mbmg001/



Tue, 24 Apr 2001 03:00:00 GMT  
 Error in VC 6.0 SP1 Compiler?

Quote:

> >     int a = sizeof(int) sizeof(double);
> Compiler interprets this like:
> int a = sizeof((int)(sizeof(double)));

Hang on -- doesn't that suggest that:

int a = sizeof int;

should work?  Because it doesn't.

M

--
   "It's the gaps between the rain that count,
     and learning how to live amongst them."
          -- Jeff Noon, _Pixel Juice_
Matt Gibson                          http://www.netgates.co.uk/mbmg001/



Tue, 24 Apr 2001 03:00:00 GMT  
 Error in VC 6.0 SP1 Compiler?

Quote:

> Hang on -- doesn't that suggest that:

> int a = sizeof int;

> should work?  Because it doesn't.

And let me just diagree with myself: thanks to Rimantas Endriukaitis I now see
what's going on.

I think that the described behaviour is correct, according to ANSI.  If the
Borland compiler doesn't like it, I think the Borland compiler is wrong.
(incidentally, CodeWarrior and PC Lint both flag it as an error.)

Cheers,

M

--
   "It's the gaps between the rain that count,
     and learning how to live amongst them."
          -- Jeff Noon, _Pixel Juice_
Matt Gibson                          http://www.netgates.co.uk/mbmg001/



Tue, 24 Apr 2001 03:00:00 GMT  
 Error in VC 6.0 SP1 Compiler?

Quote:

>> Hang on -- doesn't that suggest that:

>> int a = sizeof int;

>> should work?  Because it doesn't.

>And let me just diagree with myself: thanks to Rimantas
>Endriukaitis I now see what's going on.

>I think that the described behaviour is correct, according
>to ANSI.  If the Borland compiler doesn't like it, I think
>the Borland compiler is wrong. (incidentally, CodeWarrior
>and PC Lint both flag it as an error.)

I'll bet that if you qualified the scope with enclosing parenthesis,
Borland, CodeWarrior, and Lint would accept it as a viable line of code.  
VC++ appears to actually be correct in it's interpretation of the code
since parenthesis' aren't *required* to properly parse the code.

--
=========================================================
John Simmons - Redneck Techno-Biker (Zerex12)
http://www.members.home.net/jms1/index.html

John Simmons - Barbarian Diecast Collector
http://members.home.net/jsimm/diecast_index.html

If you want to send me email, go to either of the URL's
shown above & click "Send Me Mail" in the contents frame.
=========================================================



Thu, 26 Apr 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Error in VC 6.0 SP1 Compiler?

2. Template Bug in 6.0 SP1 (C2248 error)

3. VC 6.0 gives compiler error for map

4. vc++ 6.0 sp5 internal compiler error with /EHa

5. vc 6.0 compiler errors

6. VC++6.0/SP3 Compiler Error: INTERNAL COMPILER ERROR

7. How to use VC 7.0 C++ compiler from VC 6.0 IDE

8. Link Errors in VC.net that don't appear in VC 6.0

9. VC 4.2 link error linking static libraries from VC 6.0

10. VC 6.0 -> VC 5.0 Error

11. VARIANT Error in VC 6.0 Access error

12. Emulate VC 6.0 Compiler/Linker

 

 
Powered by phpBB® Forum Software