Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #19048

Re: Floating point support not loaded

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: Floating point support not loaded
Date 2012-03-26 06:48 -0400
Organization A noiseless patient Spider
Message-ID <jkphi1$g5j$1@dont-email.me> (permalink)
References (1 earlier) <jkkdb0$v8g$1@dont-email.me> <9a135814-206f-482c-a3f0-6e199b690b31@l7g2000vbw.googlegroups.com> <2ce3e2be-5693-4766-847b-363c75ac22fd@i2g2000vbv.googlegroups.com> <lnlimphees.fsf@nuthaus.mib.org> <20m549-jhr.ln1@voyager.wichi.de.vu>

Show all headers | View raw


On 03/26/2012 04:29 AM, Markus Wichmann wrote:
> On 24.03.2012 22:34, Keith Thompson wrote:
...
>> It's likely that you don't actually have to *execute* the call to the
>> sqrt() function to cause floating point support to be loaded.  Try
>> something like:
>>
>>     float test = 0 ? sqrt(9) : 0;
>>
>> or perhaps even:
>>
>>     sqrt;
>>
>> The latter is not a call to sqrt; it's an expression that evaluates to
>> the address of the sqrt function.  Since the result is discarded, it
>> shouldn't generate any actual code, but it might force the compiler to
>> load the floating-point code anyway.
>>
> 
> Ever heard of dead code elimination? It's a very basic optimization that
> would remove the reference to sqrt() and therefore the need to link
> against libm (or whatever that system's equal of it is).

I'm sure he has, since he mentions it in the very next line of his that
you quoted. The use of sqrt is just a trick that shouldn't be necessary
when using a fully conforming implementation of C. If this
implementation requires special command line options to load the
floating point math support needed by printf(), then it isn't fully
conforming without those options selected.

>> In both cases, a sufficiently clever compiler can recognize that the
>> code has no effect and eliminate it -- but your compiler is
>> insufficiently clever either to load the floating-point code or to
>> recognize that it doesn't need it.
>>
> 
> That's another can of worms. The way I see it, the designers of that
> system's *scanf() did a bad job, because they depend on floating-point
> support at runtime, but don't tell anyone during link time. My take on
> it is that the compiler tries linking without libm and if that doesn't
> work, tries it with libm. ...

I presume that one of those two "libm"s was supposed to be something else?
-- 
James Kuyper

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Floating point support not loaded lolzy@live.nl - 2012-03-24 03:04 -0700
  Re: Floating point support not loaded Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-03-24 04:15 -0700
  Re: Floating point support not loaded Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-03-24 08:05 -0400
    Re: Floating point support not loaded lolzy@live.nl - 2012-03-24 10:15 -0700
      Re: Floating point support not loaded lolzy@live.nl - 2012-03-24 10:51 -0700
        Re: Floating point support not loaded Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-03-24 14:27 -0400
        Re: Floating point support not loaded Keith Thompson <kst-u@mib.org> - 2012-03-24 14:34 -0700
          Re: Floating point support not loaded Markus Wichmann <nullplan@gmx.net> - 2012-03-26 10:29 +0200
            Re: Floating point support not loaded James Kuyper <jameskuyper@verizon.net> - 2012-03-26 06:48 -0400
              Re: Floating point support not loaded Markus Wichmann <nullplan@gmx.net> - 2012-03-26 13:31 +0200
                Re: Floating point support not loaded James Kuyper <jameskuyper@verizon.net> - 2012-03-26 08:42 -0400

csiph-web