public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/96613] SIGFPE on min1() with -ffpe-trap=invalid switch
Date: Mon, 17 Aug 2020 18:55:40 +0000	[thread overview]
Message-ID: <bug-96613-4-d9xYQKwGFB@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96613-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Mon, Aug 17, 2020 at 06:03:31PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96613
> 
> --- Comment #5 from anlauf at gcc dot gnu.org ---
> (In reply to kargl from comment #4)
> > I thought that this might be a good candidate for frontend fix.  
> > Similar to thomas's frontend optimizations except except the 
> > transformation is always done.  That is, we should be able to do
> > substitutions based on Table 16.3 before we even get to backend.
> 
> If frontend optimization is preferred, I'll step out of the way.
> 
> Nevertheless, one also need to address issues like:
> 
> % cat maxmin.f90
> program p
>   implicit none
>   print *, min (2.0, 1.d0)
>   print *, min (2.d0, 1.0)
>   print *, kind (min (2.0, 1.d0))
>   print *, kind (min (2.d0, 1.0))
> end program p
> 
> % gfc-11 maxmin.f90 && ./a.out 
>    1.00000000    
>    1.0000000000000000     
>            4
>            8
> 
> The only compiler I found having the same is PGI/NVIDIA.
> 
> OTOH ifort (and similarly sunf95, g95(!)) result in the expected:
> 
>    1.00000000000000     
>    1.00000000000000     
>            8
>            8

Personally, I would rather issue an error if types of the
arguments are not the same, but that ship sailed years ago.
To fix, the above, you'll need to look at iresolve.c

static void
gfc_resolve_minmax (const char *name, gfc_expr *f, gfc_actual_arglist *args)
{
  gfc_actual_arglist *a;

  f->ts.type = args->expr->ts.type;
  f->ts.kind = args->expr->ts.kind;

and re-do the conversion stuff.  AFAICT, type conversion is
not handled correctly.  The largest kind is found regardless
of the type and this kind with the type of first argument is
used to to do conversion.

  parent reply	other threads:[~2020-08-17 18:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-14  9:09 [Bug libfortran/96613] New: " thomas.huxhorn at web dot de
2020-08-14 15:58 ` [Bug libfortran/96613] " kargl at gcc dot gnu.org
2020-08-14 15:59 ` [Bug fortran/96613] " kargl at gcc dot gnu.org
2020-08-16 19:55 ` anlauf at gcc dot gnu.org
2020-08-16 19:55 ` anlauf at gcc dot gnu.org
2020-08-16 21:52 ` kargl at gcc dot gnu.org
2020-08-17 18:03 ` anlauf at gcc dot gnu.org
2020-08-17 18:55 ` sgk at troutmask dot apl.washington.edu [this message]
2020-08-17 19:05 ` anlauf at gcc dot gnu.org
2020-08-17 20:37 ` anlauf at gcc dot gnu.org
2020-08-18 19:49 ` cvs-commit at gcc dot gnu.org
2020-08-18 20:08 ` anlauf at gcc dot gnu.org
2020-08-20 18:51 ` thomas.huxhorn at web dot de

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-96613-4-d9xYQKwGFB@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).