LWN.net Logo

Advertisement

E-Commerce & credit card processing - the Open Source way!

Advertise here

Trapping on overflow

Trapping on overflow

Posted Feb 23, 2008 22:24 UTC (Sat) by giraffedata (subscriber, #1954)
In reply to: Trapping on overflow by anton
Parent article: vmsplice(): the making of a local root exploit

MIPS and Alpha have separate arithmetic instructions that trap on signed overflow ...

Nice. Do you know if there is any way to make GCC (or any other C compiler) generate such instructions?

I can understand people resisting adding instructions to handle overflow, but if I could declare in my C program "no arithmetic in here is supposed to wrap around" and get signalled to death if it does, I'd do it a lot.


(Log in to post comments)

Trapping on overflow

Posted Feb 28, 2008 21:23 UTC (Thu) by anton (guest, #25547) [Link]

Apart from asm statements and modifying gcc I don't know of a way to get gcc or other compilers to use the trapping instructions for C code.

Concerning "no arithmetic in here is supposed to wrap around", unsigned arithmetic is supposed to wrap around in standard C, only signed arithmetic is allowed to trap (or do anything else) on overflow.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds