<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>gcc emitting wrong floating point instructions?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3456/gcc-emitting-wrong-floating-point-instructions</link><description>Hi there,
I&amp;#39;m currently facing the problem, that an example as simple as 
 volatile float sum;
extern &amp;quot;C&amp;quot; int _start()
{
 float a = 1.0;
 double d = 2.2;
 sum = a + d;
 for(;;);
 
 } 
 is causing problems. 
 The compiler is invoked with -mcpu</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 13 Aug 2014 15:01:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3456/gcc-emitting-wrong-floating-point-instructions" /><item><title>RE: gcc emitting wrong floating point instructions?</title><link>https://devzone.nordicsemi.com/thread/12508?ContentTypeID=1</link><pubDate>Wed, 13 Aug 2014 15:01:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3565c70d-fad5-4e74-8235-902618cd78e4</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi, thanks for commenting on this. I will experiment a little with command line switches.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: gcc emitting wrong floating point instructions?</title><link>https://devzone.nordicsemi.com/thread/12507?ContentTypeID=1</link><pubDate>Tue, 12 Aug 2014 22:57:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:007c6ea9-838a-4894-8539-788ac10219b8</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Well the code is correct, sort of, and I don&amp;#39;t know whether it&amp;#39;s being generated by gcc or linked in from a library, probably generated. That &amp;#39;bx pc&amp;#39; jumps to the PC+4 and switches to ARM mode, which is why you&amp;#39;re ending up in the hard fault handler, in Thumb mode that&amp;#39;s not allowed. There&amp;#39;s  a clue in the function name, __aeabi_f2d_from_thumb, that looks like a thunk to the f2d (I guess that&amp;#39;s float division) library function &amp;#39;from thumb&amp;#39;.&lt;/p&gt;
&lt;p&gt;So it seems to me the compiler thinks it should be using an ARM FP library which it&amp;#39;s linked in, and has generated a correct call into ARM code for it, but you&amp;#39;re on a Thumb device.&lt;/p&gt;
&lt;p&gt;Possibilities, there&amp;#39;s another flag on the command line confusing it, perhaps try to compile that line by hand with different flags to see what you get. I see you&amp;#39;re using 4.8.4 of gcc, have you tried 4.8.3, may be a regression.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>