This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Error at division by constant zero
- From: Andrew Haley <aph at cambridge dot redhat dot com>
- To: "Unruh, Erwin" <Erwin dot Unruh at fujitsu-siemens dot com>
- Cc: gcc at gcc dot gnu dot org, yasir999 at hotmail dot com
- Date: Fri, 23 Aug 2002 10:13:24 +0100 (BST)
- Subject: Error at division by constant zero
- References: <5B7690DAE02BD411A772009027FD68CC0214A64D@mchrd23e.mch.fsc.net>
Unruh, Erwin writes:
> When dividing an integer by constant zero, the GCC does emit a library call to
> the corresponding routine. On Sparc this is .rem or .div, on Linux this might be
> __modsi3 or __divsi3.
>
> I think this is an error in expand_divmod. EXACT_POWER_OF_2_OR_ZERO_P gives
> true. So we think we could use a shift optab.
For division by zero? How?
Division by zero is an undefined operation in C - see ISO 9899 Section
6.3.5. So, in theory we can do anything. But, what is the most
useful "anything" we can do? We have chosen to preserve division by
zero so that if the processor has a divide overflow trap we'll get one
at runtime. Also, some languages (such as Java) can trap divide
overlows overflow and we need that behaviour.
Andrew.