public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Division by zero on A53 which does not raise an exception
@ 2022-11-29  4:37 Stephen Smith
  2022-11-29  8:30 ` Richard Biener
  2022-11-29 12:00 ` Szabolcs Nagy
  0 siblings, 2 replies; 3+ messages in thread
From: Stephen Smith @ 2022-11-29  4:37 UTC (permalink / raw)
  To: gcc; +Cc: binutils

I am working on a project which is using an A53 core.   The core does not 
raise an exception if there is a division by zero (for either integer or 
floating point division).

The designers chose to set status bits for the floating point case but not 
raise an exception.    With the integer division no status bits are set.

Does the GCC  compilers or Binutils assembler and linker have a way to deal 
with this issue on the ARM A53 processor?  

For Linux, was special support added in the kernel to help Glibc with this 
issue?  If so, I will comb the linux source tree.

My project is using GCC 7.3.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Division by zero on A53 which does not raise an exception
  2022-11-29  4:37 Division by zero on A53 which does not raise an exception Stephen Smith
@ 2022-11-29  8:30 ` Richard Biener
  2022-11-29 12:00 ` Szabolcs Nagy
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener @ 2022-11-29  8:30 UTC (permalink / raw)
  To: Stephen Smith; +Cc: gcc, binutils

On Tue, Nov 29, 2022 at 5:39 AM Stephen Smith via Gcc <gcc@gcc.gnu.org> wrote:
>
> I am working on a project which is using an A53 core.   The core does not
> raise an exception if there is a division by zero (for either integer or
> floating point division).
>
> The designers chose to set status bits for the floating point case but not
> raise an exception.    With the integer division no status bits are set.
>
> Does the GCC  compilers or Binutils assembler and linker have a way to deal
> with this issue on the ARM A53 processor?
>
> For Linux, was special support added in the kernel to help Glibc with this
> issue?  If so, I will comb the linux source tree.
>
> My project is using GCC 7.3.0

I'm second-guessing that you want to have an exception raised for
integer division by zero?  Since the C standard defines this as
invoking undefined behavior and GCC generally takes advantage
of this reliably getting an exception is difficult.  There's
-fsanitize=integer-divide-by-zero -fsanitize-undefined-trap-on-error
which you could use.

There are targets with options like -mcheck-zero-division but
arm is not amongst those.

Richard.

>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Division by zero on A53 which does not raise an exception
  2022-11-29  4:37 Division by zero on A53 which does not raise an exception Stephen Smith
  2022-11-29  8:30 ` Richard Biener
@ 2022-11-29 12:00 ` Szabolcs Nagy
  1 sibling, 0 replies; 3+ messages in thread
From: Szabolcs Nagy @ 2022-11-29 12:00 UTC (permalink / raw)
  To: Stephen Smith; +Cc: gcc, binutils

The 11/28/2022 21:37, Stephen Smith via Binutils wrote:
> I am working on a project which is using an A53 core.   The core does not 
> raise an exception if there is a division by zero (for either integer or 
> floating point division).

floating-point division by zero signals the FE_DIVBYZERO exception.
you can test this via fetestexcept(FE_DIVBYZERO).

integer operations must not affect fenv status flags so integer
division by zero does not do that.

if you want to *trap* division by zero, there is no reliable way
to do that in c (this is not related to particular cpus though).

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-29 12:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29  4:37 Division by zero on A53 which does not raise an exception Stephen Smith
2022-11-29  8:30 ` Richard Biener
2022-11-29 12:00 ` Szabolcs Nagy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).