Menu

#63 Faulty code generation in function "lookup"

closed-out-of-date
None
5
2004-01-21
2003-09-18
Anonymous
No

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@xtreamlok.com

Discussion

  • Karl Waclawek

    Karl Waclawek - 2003-09-24
    • milestone: 103319 -->
     
  • Karl Waclawek

    Karl Waclawek - 2003-09-24

    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.

     
  • Karl Waclawek

    Karl Waclawek - 2003-09-24
    • assigned_to: nobody --> fdrake
     
  • Fred L. Drake, Jr.

    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?

     
  • Fred L. Drake, Jr.

    • status: open --> closed-out-of-date
     
  • Fred L. Drake, Jr.

    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.

     

Log in to post a comment.

MongoDB Logo MongoDB