473,411 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

compiler bug of vc71?

I've got a little problem with the following few lines of code (copypasted
from the stopped debugger):

int extra1 = max((int)h->size - sizeof(OggStreamHeader), 0);

0148FA42 mov eax,dword ptr [h]
0148FA45 mov ecx,dword ptr [eax+0Ch]
0148FA48 sub ecx,38h
0148FA4B je COggVideoOutputPin::COggVideoOutputPin+0AEh (148FA5Eh)
0148FA4D mov edx,dword ptr [h]
0148FA50 mov eax,dword ptr [edx+0Ch]
0148FA53 sub eax,38h
0148FA56 mov dword ptr [ebp-198h],eax
0148FA5C jmp COggVideoOutputPin::COggVideoOutputPin+0B8h (148FA68h)
0148FA5E mov dword ptr [ebp-198h],0
0148FA68 mov ecx,dword ptr [ebp-198h]
0148FA6E mov dword ptr [extra1],ecx

int extra2 = (int)h->size - sizeof(OggStreamHeader);

0148FA71 mov eax,dword ptr [h]
0148FA74 mov ecx,dword ptr [eax+0Ch]
0148FA77 sub ecx,38h
0148FA7A mov dword ptr [extra2],ecx

extra2 = max(extra2, 0);

0148FA7D xor eax,eax
0148FA7F cmp dword ptr [extra2],0
0148FA83 setle al
0148FA86 dec eax
0148FA87 and eax,dword ptr [extra2]
0148FA8A mov dword ptr [extra2],eax

-----------

It's very simple to describe, extra1 becomes -4 (wrong), extra2 becomes 0
(correct). Yes, I know the first solution has some overhead, but it is very
easy to code this way because of laziness..., and it can't be a reason for
the compiler to produce wrong code either :) The question is, why can't we
see any sign of less or equal comparison in the first assembly listing? Only
one "je" is there. (btw, the compiler used a really nice trick in the second
case, considering it was just the debug build :)

Nov 17 '05 #1
2 1081

"Gabest" <ga****@freemail.hu> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl...
I've got a little problem with the following few lines of code (copypasted
from the stopped debugger):

int extra1 = max((int)h->size - sizeof(OggStreamHeader), 0);


Doh, can it be that (int)h->size - sizeof(OggStreamHeader) becomes unsigned
again? Is there any rule for such cases, like the last or "wider" decides
the type?

Nov 17 '05 #2
Gabest wrote:
It's very simple to describe, extra1 becomes -4 (wrong), extra2
becomes 0 (correct).
The result of the subtraction has the type 'unsigned int', while the literal
0 has the type 'int'. Applying the max macro to values of different types
has (I believe) unspecified behavior.
Yes, I know the first solution has some
overhead, but it is very easy to code this way because of
laziness..., and it can't be a reason for the compiler to produce
wrong code either :) The question is, why can't we see any sign of
less or equal comparison in the first assembly listing? Only one "je"
is there. (btw, the compiler used a really nice trick in the second
case, considering it was just the debug build :)


There's no relational operator because the type of the operands is
unsigned - the only unsigned number that's not greater than zero is zero
itself.

-cd
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff Epler | last post by:
Hello. Recently, Generator Comprehensions were mentioned again on python-list. I have written an implementation for the compiler module. To try it out, however, you must be able to rebuild...
13
by: Bryan Parkoff | last post by:
You may notice that switch (...) is much faster than function that can gain a big improved performance because it only use JMP instruction however function is required to use CALL, PUSH, and POP...
1
by: Alex Sedow | last post by:
Anybody know how to create libboost_filesystem-vc71-s-1_31.lib? Please help me. 1. Download boost library. 2. Run boost\build\jam_src\build.bat. After that jam-files have been created in...
10
by: Bjorn | last post by:
I'm using interfaces in C++ by declaring classes with only pure virtual methods. If then someone wants to implement the interface they needs to inherit from the class. If the implementing class...
0
by: rollasoc | last post by:
Hi, I seem to be getting a compiler error Internal Compiler Error (0xc0000005 at address 535DB439): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around...
3
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error...
6
by: Arkadiy | last post by:
Hi all, I was under impression that the ETI bug was completely fixed in VC71. However, recently I ran into a problem that makes me think otherwise. The following minimal example demonstrates the...
2
by: E.T. Grey | last post by:
#ifndef MKT_DATA_QUOTE_CHAIN_Header_ #define MKT_DATA_QUOTE_CHAIN_Header_ //#include "Quote.h" class QuoteChain/*: public Quote*/ { /*public: QuoteChain(); ~QuoteChain(); */
41
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.