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


Groups > comp.lang.c > #19010

Re: Floating point support not loaded

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Floating point support not loaded
Date 2012-03-24 14:34 -0700
Organization None to speak of
Message-ID <lnlimphees.fsf@nuthaus.mib.org> (permalink)
References <58a3b95c-55ea-4d4c-9da0-4c837348b5d0@12g2000vba.googlegroups.com> <jkkdb0$v8g$1@dont-email.me> <9a135814-206f-482c-a3f0-6e199b690b31@l7g2000vbw.googlegroups.com> <2ce3e2be-5693-4766-847b-363c75ac22fd@i2g2000vbv.googlegroups.com>

Show all headers | View raw


lolzy@live.nl writes:
> /*
>  * Encode a string according to http://tools.ietf.org/html/rfc3986#section-2.1.
> */
> void urlEncode(char *string)
> {
> 	float test = sqrt(9);
> 	int i = 0;
> 	char *buf = KhSafeMalloc(((strlen(string) * 3) + 1) * sizeof(char)),
> *end = buf;
>
> 	while (string[i] != '\0')
> 	{
> 		if ((unsigned char) isalnum(string[i]) || string[i] == '-' ||
> string[i] == '_' || string[i] == '.' || string[i] == '~')
> 			*end++ = string[i];
> 		else if (string[i] == ' ')
> 			*end++ = '+';
> 		else
> 			end += sprintf(end, "%%%.2X", string[i]);
>
> 		++i;
> 	}
>
> 	*end = '\0';
> 	strcpy(string, buf);
> 	free(buf);
> }
>
>
> 'float test = sqrt(9)' did the trick :-)

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.

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.

Of course you should have "#include <math.h>" if you refer to the sqrt
function.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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