[Bug cobol/126409] New: cobol vs. LoongArch: passing floating-point argument is broken

"xry111 at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126409

            Bug ID: 126409
           Summary: cobol vs. LoongArch: passing floating-point argument
                    is broken
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: cobol
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xry111 at gcc dot gnu.org
  Target Milestone: ---

identification division.
        program-id.  prog.
        data division.
        working-storage section.
        01 var1 float-short         .
        01 var1r float-short        .
        procedure division.
            move 1.234E30 to var1
            call     "rvar1" using by value var1 returning var1r
            display     var1r
            goback.
        end program prog.

        identification division.
        program-id. rvar1.
        data division.
        linkage section.
        01  var    float-short.
        01  varr   float-short.
        procedure division using by value var returning varr.
            move var to varr.
        end program rvar1.

outputs:

6.445972936E-44

(or some other garbage) on LoongArch.  The reason is when prog() is gimplified
it uses a vararg function_decl for rvar1, i.e. float rvar1(...), but when
rvar1() itself is gimplified it uses a different function_decl with fixed
arguments, i.e. float rvar1(float).

On LoongArch a float-point argument can be passed via FPR if it's fixed, but
not if it's varadic.  Thus the calling convention is broken here.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.