[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bits wrap when leftshifting non-constant amounts
- To: freebsd-chat_(_at_)_FreeBSD_(_dot_)_ORG, deeptech71_(_at_)_gmail_(_dot_)_com
- Subject: Re: bits wrap when leftshifting non-constant amounts
- From: Oliver Fromme <olli_(_at_)_lurza_(_dot_)_secnetix_(_dot_)_de>
- Date: Wed, 13 Feb 2008 11:39:38 +0100 (CET)
- Cc:
- Reply-to: freebsd-chat_(_at_)_FreeBSD_(_dot_)_ORG, deeptech71_(_at_)_gmail_(_dot_)_com
deeptech71_(_at_)_gmail_(_dot_)_com wrote:
> My gcc 3.4.6 behaves weirdly when left shifting, and I couldn't
> find any info on this.
> [...]
> It seems that lsh is first moduloed with the width of int. What the hell?
C99 standard, section 6.5.7 "Bitwise shift operators",
page 84:
"If the value of the right operand is negative or is
greater than or equal to the width of the promoted left
operand, the behaviour is undefined."
Best regards
Oliver
--
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart
FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd
"C is quirky, flawed, and an enormous success."
-- Dennis M. Ritchie.
_______________________________________________
freebsd-chat_(_at_)_freebsd_(_dot_)_org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-chat
To unsubscribe, send any mail to "freebsd-chat-unsubscribe_(_at_)_freebsd_(_dot_)_org"
Visit your host, monkey.org