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

SourceForge.net noreply at sourceforge.net
Wed Sep 24 11:47:24 EDT 2003


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

Category: None
Group: None
Status: Open
Resolution: None
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: 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