Re: Thou shalt have no other gods before the ANSI C standard
From: Hank Oredson (horedson_at_earthlink.net)
Date: 02/28/05
- Next message: Randy Howard: "Re: Thou shalt have no other gods before the ANSI C standard"
- Previous message: Hank Oredson: "Re: Thou shalt have no other gods before the ANSI C standard"
- In reply to: Randy Howard: "Re: Thou shalt have no other gods before the ANSI C standard"
- Next in thread: Douglas A. Gwyn: "Re: Thou shalt have no other gods before the ANSI C standard"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 28 Feb 2005 03:07:10 GMT
-- ... Hank http://home.earthlink.net/~horedson http://home.earthlink.net/~w0rli "Randy Howard" <randyhoward@FOOverizonBAR.net> wrote in message news:MPG.1c8c40beff2c372398a0e6@news.verizon.net... > In article <opsmvwoptdzgicya@hyrrokkin>, tom@kednos.com says... >> On Sun, 27 Feb 2005 20:22:15 -0500, Douglas A. Gwyn <DAGwyn@null.net> >> wrote: >> > You won't be able to address the question about what >> > optimizations C compilers perform by exhibiting PL/I >> > examples. >> >> Doesn't matter whether it is PL/I or C, we were discussing, I >> thought, code hoisting in one case strlen and in the other length. > > Perhaps some have taken a more generic path, but I thought the > question was fairly specific: > > Will a C compiler (with or without optimizer) hoist a > strlen() call out of a for loop, particular the body of the > "for(...)" itself? > > I prefer empirical evidence to theory on this, and so far, > half a dozen compilers have answered "no" to this question. > Again, if anyone can point to one that answers "yes", I'd > like to know. Here is Borland BCC 4.02, which was at hand on this machine: No hoisting. ; for (n = 0; n < strlen(argv[1]); n++); mov word ptr [bp-10],0 jmp short @7@86 @7@58: inc word ptr [bp-10] @7@86: les bx,dword ptr [bp+8] push dword ptr es:[bx+4] call far ptr _strlen add sp,4 cmp ax,word ptr [bp-10] ja short @7@58 > The more important question of course is that if the > outcome is compiler dependent (at best) and likely to > fail on the most commonly used C compilers in existence, > why would a programmer *not* hoist the call themselves? > > I am afraid that the answer may be that far too many > people, comprised of students, textbook authors, teachers > and even experienced developers think that it will, and > never bother to find out for themselves. > > You can add the whole "what does volatile really do?", and > the endless debates on what magical properties it may or > may not convey on an object (C sense) to this debate as > a corollary. > > -- > Randy Howard (2reply remove FOOBAR) > "Rally Mohawks, and bring your axes > and tell King George we'll pay no taxes"
- Next message: Randy Howard: "Re: Thou shalt have no other gods before the ANSI C standard"
- Previous message: Hank Oredson: "Re: Thou shalt have no other gods before the ANSI C standard"
- In reply to: Randy Howard: "Re: Thou shalt have no other gods before the ANSI C standard"
- Next in thread: Douglas A. Gwyn: "Re: Thou shalt have no other gods before the ANSI C standard"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|