Surely the only important issue here is (as Maxim said) that any complier
should issue an error that not all control paths return a value. Any that
don’t have not parsed it correctly.
Since the source code is invalid C the results if it does (appear to)
compile must be garbage.
I think we all find complier anomalies from time to time, presumably most
people, like me, find a workaround and move on. Reporting it to the supplier
is more public spirited, but we seldom have time.
BTW I thought goto was a valid part of the language. Most of us were taught
that a good rule of thumb is to avoid them as there is often a better
architecture. These rules are of course for the the guidance of the wise
(and the obediance of ??? - I can’t remember the original quote…).
Mike
----- Original Message -----
From: raj_r
To: Windows System Software Devs Interest List
Sent: Thursday, May 17, 2007 9:08 AM
Subject: Re: [ntdev] Strange problem with VC++ compiler because of goto
well not hoping to turn this thread into a you you me me flame war
but gotos do have thier use and i ve seen some very good code being
being emitted when using gotos
and being constantly fed wtih propaganda against using gotos i asked someone
about the phenomena
i have a the best possible code emitted by the compiler when i am using goto
in my c source (no embedded jumps inserted but compiler was clever
enough to seamlessly merge the code into a single proc with goto)
but it seems every tom dick and harry and his poodle out there is
fanatic about me not using goto
and he replied something in this vein
using goto is like dividing by zero
in school mathematics dividing by zero is impossible cannot be done
in highschool mathematics you get the tone of dividing by zero is
acceptable with certain caveats
when you are doing college mathematics
you can certainly divide by zero and derive a result that tends to some
limit
not sure the analogy fits in or not but i do believe in some cases
gotos have the best possible outcome of compiled code
no flames please
On 5/17/07, Edouard A. wrote:
> To avoid this problem the best is to have strict guidelines about that
> kind
> of stuff within your team(s). When new people come into the team they are
> made aware of the rules, which are:
>
> 1/You do not talk about GOTO
> 2/You DO NOT talk about GOTO
>
> –
>
> EA
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com [mailto:bounce-286997-
> > xxxxx@lists.osr.com] On Behalf Of Robert Kennett
> > Sent: jeudi 17 mai 2007 09:06
> > To: Windows System Software Devs Interest List
> > Subject: Re: [ntdev] Strange problem with VC++ compiler because of goto
> >
> > I find that goto’s are one of the most singularly useful constructs
> > there is. Just one or two, placed at strategic points in the code, will
> > derail any serious code review while the participant flame each other
> > into fits and ignoring the substance of the code. Goto’s also work
> > great
> > for turning ntdev into slashdot. Any thoughts on genetically altered
> > corn?
> >
> >
> >
> > > I don’t mean the snap but.
> > >
> > >
> > >
> > > You shouldn’t use gotos. Avoid them. In a world of exceptions and
> > > encapsulated init/deinit there is no need for gotos. I recently saw a
> > > code with gotos INSIDE a loop that went UP and since that minute I
> > > decided that my tolerance toward gotos ended.
> > >
> > >
> > >
> > > –
> > >
> > > EA
> > >
> > > From: xxxxx@lists.osr.com
> > > [mailto:xxxxx@lists.osr.com] *On Behalf Of Raja Reddy
> > > Sent: jeudi 17 mai 2007 06:44
> > > To: Windows System Software Devs Interest List
> > > Subject: [ntdev] Strange problem with VC++ compiler because of goto
> > >
> > > Hello,
> > >
> > > Today I found a serious problem in the following code when I compiled
> > > with VC++ 6.
> > >
> > > The installed compiler & linker versions are 12.00.8804, 6.00.8447 on
> > > x86 system respectively.
> > >
> > > #include <stdio.h>
> > >
> > > int alloc()
> > > {
> > > return 0;
> > > }
> > >
> > > int main(int argc, char argv)
> > > {
> > > printf(“Testing!\n”);
> > >
> > > if(alloc() == 0)
> > > goto Radhe;
> > >
> > > return 0;
> > >
> > > Radhe:
> > >
> > > printf(“Hello\n”);
> > >
> > > }
> > >
> > > I expected that “Hello” will be printed just once because, the if
> > > statement jumps the instruction pointer to the label.
> > >
> > > But “Hello” is priting always till I kill the process.
> > >
> > > When I check the assembly code, I found a JMP instruction right after
> > > printf(“Hello\n”) line, instead of a RET instruction.
> > >
> > > I don’t know whether this is known bug in VC compilers or microsoft
> > > standard. I just want to share this with all of experts here.
> > >
> > > If this is the wrong place to post, please ignore.
> > >
> > > Regards,
> > >
> > > Raja Reddy.
> > >
> > > ---------------------------------------------------------------------
> > —
> > >
> > > Park yourself in front of a world of choices in alternative vehicles.
> > > Visit the Yahoo! Auto Green Center.
> > >
> > http:> > _ylc=X3oDMTE5cDF2bXZzBF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDZ3JlZW4tY2
> > VudGVy>
> > > — Questions? First check the Kernel Driver FAQ at
> > > http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the
> > > List Server section of OSR Online at
> > > http://www.osronline.com/page.cfm?name=ListServer
> > >
> > >
> > > —
> > > Questions? First check the Kernel Driver FAQ at
> > > http://www.osronline.com/article.cfm?id=256
> > >
> > > To unsubscribe, visit the List Server section of OSR Online at
> > > http://www.osronline.com/page.cfm?name=ListServer
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > To unsubscribe, visit the List Server section of OSR Online at
> > http://www.osronline.com/page.cfm?name=ListServer
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer</http:></stdio.h>