https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122082

--- Comment #8 from kargls at comcast dot net ---
(In reply to Fred J. Tydeman from comment #7)
> I see two statements in comment #2.  I do not see any questions there.
> In comment #1, I do see a question.  I am testing that the imaginary part is
> 0,
> which is the correct result.
> 
> Another reference implementation can be found in:
> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1399.htm

All heck.  I meant comment #1.  You have not answered the question.
So, I'll pose it again?

    assert( FE_OVERFLOW|FE_INEXACT == flags );

What are testing with this line of code?  I suspect it isn't
doing what you think it should be doing.

Here's a helpful hint from clang.

% cc -o z a.c -lm
...
a.c:25:24: warning: | has lower precedence than ==; == will be evaluated first
[-Wparentheses]
   25 |     assert( FE_OVERFLOW|FE_INEXACT == flags );
      |     ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Sure enough, clang also trigger your imaginary test.

 % ./z
Assertion failed: (0.f == cimagf(fc26)), function main, file a.c, line 27.
Abort (core dumped)


Now, if you had correctly written code with parenthesis, you get

% ./z
Assertion failed: ((FE_OVERFLOW|FE_INEXACT) == flags), function main, file a.c,
line 25.
Abort (core dumped)

which means you'll never see the issue with imaginary part.

Reply via email to