Hi fellows, recently I found a strange behavior, which I guess is a compiler error: I have a quite trivial piece of code: static float fvar; float get_var(void) { return fvar; } This function is exported via a header as: float get_var(void); When it is called at another location, the return value of get_var() retrieves the correct value in register r0, but then before the code is used in the further context, it is converted by an extra instruction f2 = float r0; which spoils the result. Did anybody else see such a behavior? It is not always reproducable - which means that it does not happen at all return parameters of type float. Since it doesn't happen when I isolate the above function, I guess that there is some dependency of my context. I'd appreciate any hint which leads me to the reason behind that issue. Thanks Bernhard |
|
Compiler error (Sharc 21161) ?!
Started by ●November 23, 2004
Reply by ●November 24, 20042004-11-24
Shame upon me! In fact, I forgot the #include "header", since it had to be placed at different locations. I didn't check this at first, because I believed that I had switched the warning on, which should have indicated this. But that warning was not active, actually. Thanks for this hint. It's often somebody else who forces me to think the obvious... Bernhard Am Dienstag, 23. November 2004 16:14 schrieben Sie: > Most C compilers will do that if you forget to include the > prototype in the calling function. > If C doesn't know what the return parameter is, it assumes it is an > integer. > Did you remember to include the header file in the calling routine? > --- In , Bernhard Holzmayer > > <Holzmayer.Bernhard@F...> wrote: > > Hi fellows, > > > > recently I found a strange behavior, which I guess is a compiler > > error: > > > > I have a quite trivial piece of code: > > > > static float fvar; > > > > float get_var(void) > > { > > return fvar; > > } > > > > This function is exported via a header as: > > float get_var(void); > > > > When it is called at another location, > > the return value of get_var() retrieves the correct value in > > register r0, > > > but then before the code is used in the further context, > > it is converted by an extra instruction > > f2 = float r0; > > > > which spoils the result. > > > > Did anybody else see such a behavior? > > > > It is not always reproducable - which means that it does not > > happen at all return parameters of type float. > > > > Since it doesn't happen when I isolate the above function, I > > guess > > that there > > > is > > some dependency of my context. > > > > I'd appreciate any hint which leads me to the reason behind that > > issue. > > > > Thanks > > > > Bernhard |
|
Reply by ●November 24, 20042004-11-24
Hi Bernhard, Something similar happened to me recently (although I found out that it was MY mistake). See this thread at comp.dsp http://tinyurl.com/7y96v Additionally, see this thread, which I started and YOU replied to (and almost solved) http://tinyurl.com/3l44m Regards, JaaC --- Bernhard Holzmayer <> wrote: > > > Hi fellows, > > recently I found a strange behavior, which I guess > is a compiler error: > > I have a quite trivial piece of code: > > static float fvar; > > float get_var(void) > { > return fvar; > } > > This function is exported via a header as: > float get_var(void); > > When it is called at another location, > the return value of get_var() retrieves the correct > value in register r0, > but then before the code is used in the further > context, > it is converted by an extra instruction > f2 = float r0; > > which spoils the result. > > Did anybody else see such a behavior? > > It is not always reproducable - which means that it > does not happen > at all return parameters of type float. > > Since it doesn't happen when I isolate the above > function, I guess that there > is > some dependency of my context. > > I'd appreciate any hint which leads me to the reason > behind that issue. > > Thanks > > Bernhard __________________________________ |
Reply by ●November 24, 20042004-11-24
Oh, boy... I'm sorry I read your question too late. Now we both will pay better attention to make sure of including the headers! JaaC --- Bernhard Holzmayer <> wrote: > > > Shame upon me! > > In fact, I forgot the #include "header", since it > had to be > placed at different locations. > > I didn't check this at first, because I believed > that I had > switched the warning on, which should have indicated > this. > But that warning was not active, actually. > > Thanks for this hint. > It's often somebody else who forces me to think the > obvious... > > Bernhard > > Am Dienstag, 23. November 2004 16:14 schrieben Sie: > > Most C compilers will do that if you forget to > include the > > prototype in the calling function. > > If C doesn't know what the return parameter is, it > assumes it is an > > integer. > > Did you remember to include the header file in the > calling routine? ===== Jaime Andr Aranguren Cardona __________________________________ |