🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.msdos.programmer
3 messages
3 total messages Started by Dan Lanciani Fri, 09 Feb 1990 00:25
new MSC 5.1 bug?
#1267
Author: Dan Lanciani
Date: Fri, 09 Feb 1990 00:25
32 lines
1274 bytes
	The following useless program illustrates what I think is
a bug in the loop optimization code.  It appears that the compiler
becomes confused and believes that p1 and p2 are equal even when
the code within the if statement is not executed.  Compiling with
-Od produces correct results.  In case it isn't obvious, this
loop abstracts a search (with intent to delete) from a linked list.
If this example is perhaps too far reduced in content, the original
bug tripper can be found in the Sun rpc portmapper daemon's
deregistration function.

				Dan Lanciani
				ddl@harvard.*

struct foo {
	int a, b;
	struct foo *next;
} protofoo = { 1, 2 }, *foo = &protofoo;

main()
{
	struct foo *p1, *p2;

	for (p1 = 0, p2 = foo;;) {
		if (p2->a != protofoo.a || p2->b != protofoo.b) {
			p1 = p2;
			p2 = p2->next;
			continue;
		}
		printf("p1 = %x, p2 = %x\n", p1, p2);
	}
}
Re: new MSC 5.1 bug?
#1271
Author: Dan Lanciani
Date: Fri, 09 Feb 1990 16:29
18 lines
1115 bytes
In article <90040.115357CMH117@PSUVM.BITNET>, CMH117@psuvm.psu.edu (Charles Hannum) writes:
| In article <1537@husc6.harvard.edu>, ddl@husc6.harvard.edu (Dan Lanciani) says:
| >
| >                printf("p1 = %x, p2 = %x\n", p1, p2);
| 
| Your problem may be that you are printing out the pointers as short (16-bit)
| integers.  Try:
| 
|     printf("p1 = %p, p2 = %p\n", p1, p2);
| 

	No, this is small model and I don't really want to print
the pointers at all, I (or rather the portmap program) want to use them...
Just take a look at the generated .asm code.  The compiler believes
that both p1 and p2 are in register bx.

				Dan Lanciani
				ddl@harvard.*
Re: new MSC 5.1 bug?
#1269
Author: Charles Hannum
Date: Fri, 09 Feb 1990 16:53
22 lines
1178 bytes
In article <1537@husc6.harvard.edu>, ddl@husc6.harvard.edu (Dan Lanciani) says:
>
>                printf("p1 = %x, p2 = %x\n", p1, p2);

Your problem may be that you are printing out the pointers as short (16-bit)
integers.  Try:

    printf("p1 = %p, p2 = %p\n", p1, p2);

%p is the Turbo C mnemonic for "pointer".  If MSC doesn't support this, use:

    printf("p1 = %lx, p2 = %lx\n", p1, p2);

Note that I am assuming that you are using a large data model.  If not, I don't
have a clue.


Virtually,
- Charles Martin Hannum II       "Klein bottle for sale ... inquire within."
    (That's Charles to you!)     "To life immortal!"
  cmh117@psuvm.{bitnet,psu.edu}  "No noozzzz izzz netzzzsnoozzzzz..."
  c9h@psuecl.{bitnet,psu.edu}    "Mem'ry, all alone in the moonlight ..."
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads