[Expat-bugs] [ expat-Patches-808331 ] Faulty code generation in function "lookup"

SourceForge.net noreply at sourceforge.net
Wed Jan 21 15:28:55 EST 2004


Patches item #808331, was opened at 2003-09-18 01:35
Message generated for change (Comment added) made by fdrake
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=310127&aid=808331&group_id=10127

Category: None
Group: None
>Status: Closed
>Resolution: Out of Date
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Faulty code generation in function "lookup"

Initial Comment:
The function "lookup" in source "xmlparse.c" generates 
faulty code when built for a PocketPC2002 device in 
eMbedded Visual C++ v3.0.  Note that this only occurs 
for a release build, and not for a debug build.

Specifically this block of code at line 5306:

for (i = h & (table->size - 1);
   table->v[i];
   i == 0 ? i = table->size - 1 : --i) {
   if (keyeq(name, table->v[i]->name))
      return table->v[i];
    }

The return statement is generated as a branch to the 
return statement at the end of the function.  The code 
generation fault is in the failure to shift the index i to 
account for the size of the elements of v. 

The alternative is to declare a local variable of type 
NAMED ** to be assigned in the condition clause of the 
for loop and return that instead.

NAMED **n;
for (i = h & (table->size - 1);
   (n = table->v[i]) != NULL;
    i == 0 ? i = table->size - 1 : --i) {
      if (keyeq(name, table->v[i]->name))
        return n;
    }

email address: adam at xtreamlok.com

----------------------------------------------------------------------

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2004-01-21 15:28

Message:
Logged In: YES 
user_id=3066

Closing this as out-of-date since it hasn't been confirmed
for the current code, which contains changes to the relevant
code made since the report was filed.

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2003-10-07 22:04

Message:
Logged In: YES 
user_id=3066

What version of Expat was this problem found in?
The looping construct in the current code has changed from a
for-loop to a while-loop; does the problem still show up
when using the CVS version of Expat?

----------------------------------------------------------------------

Comment By: Karl Waclawek (kwaclaw)
Date: 2003-09-24 11:45

Message:
Logged In: YES 
user_id=290026

Thank you for the info.

This does not seem to be  a bug, but rather a workaround
for a faulty compiler. Re-classified as a patch.

Assigned to Fred for comment.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=310127&aid=808331&group_id=10127



More information about the Expat-bugs mailing list