<?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>behaviour | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/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>Sun, 07 Feb 2021 11:56:35 +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>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>Handle with care &#8211; C programming</title>
		<link>https://learncgames.com/handle-with-care-c-programming/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=handle-with-care-c-programming</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 08 Feb 2021 00:00:48 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[behaviour]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2634</guid>

					<description><![CDATA[<p>If you had programmed in say BASIC before learning C then you&#8217;d be used to a world where the worst that could happen might be a divide-by-zero crash or a hang-up due to an infinite loop. But comes to C and it has a whole raft of undefined and unexpceted behaviours. Just how big is [&#8230;]</p>
The post <a href="https://learncgames.com/handle-with-care-c-programming/">Handle with care – C programming</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;:191,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/clker-free-vector-images-3736\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=304093&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260115073407\/https:\/\/pixabay.com\/users\/clker-free-vector-images-3736\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:32:53&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-12 08:13:07&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-27 13:19:22&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-02-27 13:19:22&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:192,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=304093&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 12:32:55&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-12 08:12:57&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-27 13:19:20&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-02-27 13:19:20&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:193,&quot;href&quot;:&quot;https:\/\/gist.github.com\/Earnestly\/7c903f481ff9d29a3dd1&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251127024104\/https:\/\/gist.github.com\/Earnestly\/7c903f481ff9d29a3dd1&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:32:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 08:13:05&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 13:19:21&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-02-27 13:19:21&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:194,&quot;href&quot;:&quot;http:\/\/port70.net\/~nsz\/c\/c99\/n1256.html#J.2&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260107044711\/http:\/\/port70.net\/~nsz\/c\/c99\/n1256.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:32:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 08:13:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 13:19:20&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-02-27 13:19:20&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:195,&quot;href&quot;:&quot;http:\/\/port70.net\/~nsz\/c\/c99\/n1256.html#5.2.4.1&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260107044711\/http:\/\/port70.net\/~nsz\/c\/c99\/n1256.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:33:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 08:12:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 13:19:23&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-02-27 13:19:23&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_2635" aria-describedby="caption-attachment-2635" style="width: 300px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-2635" src="https://learncgames.com/wp-content/uploads/2021/02/sign-304093_640-300x264.png" alt="Warning sign" width="300" height="264" srcset="https://learncgames.com/wp-content/uploads/2021/02/sign-304093_640-300x264.png 300w, https://learncgames.com/wp-content/uploads/2021/02/sign-304093_640.png 640w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-2635" class="wp-caption-text">Image by <a href="https://pixabay.com/users/clker-free-vector-images-3736/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=304093">Clker-Free-Vector-Images</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=304093">Pixabay</a></figcaption></figure>
<p>If you had programmed in say BASIC before learning C then you&#8217;d be used to a world where the worst that could happen might be a divide-by-zero crash or a hang-up due to an infinite loop. But comes to C and it has a whole raft of undefined and unexpceted behaviours.</p>
<p>Just how big is that list of undefined behaviours? Would you believe 193? A developer with the user name Earnestly on GitHub has compiled <a title="Link to list of undefined behaviours" href="https://gist.github.com/Earnestly/7c903f481ff9d29a3dd1" target="_blank" rel="nofollow noopener">a list of 193 undefined behaviours</a>. MInd you, it came from a 2007 draft C99 specification which <a title="Link to 2007 draft of C99 specification" href="http://port70.net/~nsz/c/c99/n1256.html#J.2" target="_blank" rel="nofollow noopener">you can find here</a>. Note, if you scroll up a bit you can also find a list of unexpected behaviours such as what happens when you call malloc with 0 as a parameter.</p>
<p>Even more interesting take a look at <a href="http://port70.net/~nsz/c/c99/n1256.html#5.2.4.1" name="5.2.4.1">5.2.4.1 Translation limits</a> which is a list of maximums in the document. Such as 1023 cases in a switch statement. or 127 nesting levels of blocks or 63 nesting levels of conditional inclusion. If you&#8217;ve ever wondered how nested #include files can go, it turns out it&#8217;s 15.</p>
<p>I wouldn&#8217;t bother trying to learn all the undefined or unexpected behaviours. You just have to know how to write code that doesn&#8217;t make any assumptions for instance when a signed int overflows what happens? Or if you add an unsigned int to a signed int? Best if you can, not doing these things in the first place. If you do, it might work ok for you on your computer but if someone else runs it on a different system. it may behave quite differently.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/handle-with-care-c-programming/">Handle with care – C programming</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">2634</post-id>	</item>
	</channel>
</rss>
