PR# 14749 c compiler behaves differently than eiffel on divide or mod by zero

Problem Report Summary
Submitter: soapy2357
Category: C Compilation
Priority: Medium
Date: 2008/08/21
Class: Bug
Severity: Serious
Number: 14749
Release: 6.2
Confidential: No
Status: Analyzed
Environment: EiffelStudio 6.2 on Windows XP with Microsoft Visual Studio .Net 2003
Synopsis: c compiler behaves differently than eiffel on divide or mod by zero

The attached snippet results in "1.#INF" when compiled in Eiffel. But c-compilation fails with: "error C2124: divide or mod by zero".
To Reproduce
Melt and finalize the attached snippet to see the difference.
Problem Report Interactions
From:soapy2357    Date:2008/08/27    Download   
Well, actually I don't care ;-) Feel free to handle it in whatever way you prefer...
In my opinion (as Eiffel user), there should not be a different behavior in C and in Eiffel. So C should be adapted to give the same result. This of course depends on the defined behavior of divisions by zero. If in Eiffel a infinite results, then so should in C (assuming an exception will be raised).

From:manus_eiffel    Date:2008/08/26    Status: Analyzed    Download   
The main issue is that when melted the interpreter is allowed to perform the operation which result in an infinite value. However the C compiler rejects the code because it assumes this is not what the author intended. Clearly this is an over zealous C compiler.

We could potentially prevent the code generation of 0 in this case, but I'm not sure if this is worthwhile.

What is your feeling on this?

From:soapy2357    Date:2008/08/21    Download   
Attachments for problem report #14749

Attachment: c error - divide or mod by zero.e     Size:216