<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Unexpected behaviour | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/unexpected-behaviour/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Thu, 10 Sep 2020 10:32:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>Unexpected behaviour | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>Undefined behaviour in C</title>
		<link>https://learncgames.com/undefined-behaviour-in-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=undefined-behaviour-in-c</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 12 Sep 2020 23:00:51 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Unexpected behaviour]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=1386</guid>

					<description><![CDATA[<p>One of C&#8217;s not so brilliant features is the range of Undefined Behaviour (UB). Things like using an uninitialised variable or having an int variable overflow don&#8217;t have behaviour defined; thus it is UB and you cannot accurately predict what will happen. Likewise accessing a NULL pointer can cause odd behaviour. It gets more sophisticated [&#8230;]</p>
The post <a href="https://learncgames.com/undefined-behaviour-in-c/">Undefined behaviour in C</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:523,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/johnhain-352999\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1820492&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251119080635\/https:\/\/pixabay.com\/users\/johnhain-352999\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 15:46:14&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-10 06:26:35&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-17 03:19:51&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-26 15:47:26&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-05 18:13:33&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-11 14:25:57&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-22 06:52:34&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-28 19:31:30&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-02 15:24:43&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-13 23:22:13&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-17 11:56:04&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-21 06:35:26&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 06:35:26&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:524,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1820492&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205102120\/https:\/\/pixabay.com\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 15:46:16&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-10 06:26:35&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-17 03:19:52&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-26 15:47:22&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-05 18:13:31&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-11 14:25:56&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-22 06:52:34&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-28 19:31:31&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-02 15:24:43&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-13 23:22:13&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-17 11:56:00&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-21 06:35:26&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 06:35:26&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:525,&quot;href&quot;:&quot;https:\/\/blog.llvm.org\/posts\/2011-05-13-what-every-c-programmer-should-know&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20201207060546\/https:\/\/blog.llvm.org\/posts\/2011-05-13-what-every-c-programmer-should-know\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 15:46:18&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-17 03:19:52&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-05 18:13:32&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-11 14:25:57&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-22 06:52:35&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-28 19:31:31&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-02 15:24:48&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-13 23:22:13&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-19 07:30:21&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 07:30:21&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_1387" aria-describedby="caption-attachment-1387" style="width: 300px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-1387" src="https://learncgames.com/wp-content/uploads/2020/09/chaos-1820492_640-300x225.jpg" alt="Unexpected" width="300" height="225" srcset="https://learncgames.com/wp-content/uploads/2020/09/chaos-1820492_640-300x225.jpg 300w, https://learncgames.com/wp-content/uploads/2020/09/chaos-1820492_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-1387" class="wp-caption-text">Image by <a href="https://pixabay.com/users/johnhain-352999/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1820492">John Hain</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1820492">Pixabay</a></figcaption></figure>
<p>One of C&#8217;s not so brilliant features is the range of Undefined Behaviour (UB). Things like using an uninitialised variable or having an int variable overflow don&#8217;t have behaviour defined; thus it is UB and you cannot accurately predict what will happen. Likewise accessing a NULL pointer can cause odd behaviour. It gets more sophisticated than that. What if you type cast an int to a float?</p>
<p>The LLVM blog have an interesting set of <a title="Link to LLVM blog on Undefined behaviour in C" href="https://blog.llvm.org/posts/2011-05-13-what-every-c-programmer-should-know/" target="_blank" rel="nofollow noopener noreferrer">posts on UB</a> and it&#8217;s definitely worth reading. I&#8217;ve done a lot of C programming, so I&#8217;m rarely surprised by my programs but its useful to know about these things. In my case, I started with assembler programming and then learnt C++ and C in that order so my perspective has always been to try and understand whats going on deep down.</p>The post <a href="https://learncgames.com/undefined-behaviour-in-c/">Undefined behaviour in C</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1386</post-id>	</item>
	</channel>
</rss>
