[chbot] Pop quiz C

Stephen Irons stephen.irons at clear.net.nz
Wed Apr 26 00:16:30 BST 2017


It looks as though the compiler could do anything it wanted to because the
code invokes undefined behaviour by attempting to shift (what looks like) a
32-bit integer type by more than the number of bits in that type.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf, page numbered
85, physical page number 97

This is a draft C99 with TC3; I hope it has not changed since then.

Stephen Irons



On 26 April 2017 at 10:04, hamster <hamster at snap.net.nz> wrote:

> Sorry - no chocolate fish this time
>
> What is the value of a?
>
>   a = 0xFFFFFFFF << 34;
>
> Have you checked your answer?
>
>
>
>
>
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.linuxnut.co.nz
> http://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20170426/20f2dc02/attachment-0001.html>


More information about the Chchrobotics mailing list