Article View: gnu.gcc.bug
Article #189Re: gcc-Optimize
From: Michael Salmon
Date: Fri, 24 Jul 1992 08:25
Date: Fri, 24 Jul 1992 08:25
89 lines
2920 bytes
2920 bytes
In article <9207221341.AA22022@sunmanager.lrz-muenchen.de>,
a2824ak@sunmanager.lrz-muenchen.de (Thomas Kaiser) writes:
|> Dear Sirs:
|>
|> i discovered an bug, when gcc -g -O removed (optimized) a statement. It
|> removes count-- from the example.
|>
|> With regards
|>
|> Thomas Kaiser
|> Leibniz Supercomputing Centre
|> Muenchen
|> Germany
|>
|> --
|> -------------------------------------------------------------------------
|> Thomas Kaiser Internet: kaiser@sunmanager.lrz-muenchen.de
|> LRZ-Muenchen X400: C=DE;A=DBP;P=LRZ-MUENCHEN;OU=LRZ;S=Kaiser
|> -------------------------------------------------------------------------
|>
|>
|> ------------------------------------------------------------------
|> int make_snmp_query(ip_address, variable, the_community, count)
|>
|> char *ip_address;
|> char *variable;
|> char *the_community;
|> int count;
|>
|> {
|> int i;
|>
|> alarm(10);
|> if (setjmp(env)) {
|> printf("xifload: receive timed out from %s\n", ip_address);
|> close(s);
|> for (i=0; i<num_malloc; i++)
|> free(malloc_table[i]);
|> num_malloc = 0;
|> if (count <= 1)
|> return -1;
|> else {
|> count--; <------------------ will be removed
|> alarm(10);
|> }
|> }
|> make_the_query(ip_address, variable, the_community);
|> alarm(0);
|> for (i=0; i<num_malloc; i++)
|> free(malloc_table[i]);
|> num_malloc = 0;
|> return 0;
|> }
While this is undoubtably frustrating I don't see how gcc can be
expected to understand your function without including setjmp as an
element of the language. As I see it gcc believes that count isn't used
after your decrement so why decrement it. I think that something like
this will work without problem:
{
if (setjmp(env)) {
printf("xifload: receive timed out from %s\n", ip_address);
close(s);
}
while (num_malloc > 0)
free(malloc_table[--num_malloc]);
if (count-- > 0) {
alarm(10);
make_the_query(ip_address, variable, the_community);
alarm(0);
}
while (num_malloc > 0)
free(malloc_table[--num_malloc]);
num_malloc = 0; /* shouldn't be required */
return count > 0 ? 0 : -1;
}
--
Michael Salmon
#include <standard.disclaimer>
#include <witty.saying>
#include <fancy.pseudo.graphics>
Ericsson Telecom AB
Stockholm
Technical Details
Message-ID:
<1992Jul24.082553.4960@ericsson.se>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!eos.ericsson.SE!etxmesaReferences:
<9207221341.AA22022@sunmanager.lrz-muenchen.de>Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!eos.ericsson.SE!etxmesa From: etxmesa@eos.ericsson.SE (Michael Salmon) Subject: Re: gcc-Optimize Message-ID: <1992Jul24.082553.4960@ericsson.se> Sender: gnulists@ai.mit.edu Reply-To: etxmesa@eos.ericsson.se (Michael Salmon) Organization: Ericsson Telecom AB References: <9207221341.AA22022@sunmanager.lrz-muenchen.de> Distribution: gnu Date: Fri, 24 Jul 1992 08:25:53 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 90