Menu

#890 Bad @N stdcall suffix for non-trivial byval type parameters with -gen gcc

closed
nobody
mangling (4)
compiler
2018-09-26
2018-07-18
dkl
No

-gen gcc gives different @N stdcall suffix than -gen gas for procedures with non-trivial byval parameters:

type complextype
    bigdata(0 to 1000-1) as byte
    declare destructor()
end type

destructor complextype()
end destructor

declare sub a(byval as string)
declare sub b(byval as complextype)

a("")

dim x as complextype
b(x)

'' fbc 1.05.0 target win32 -gen gas
'' 2.o:fake:(.text+0x64): undefined reference to `A@12'
'' 2.o:fake:(.text+0xa9): undefined reference to `B@1000'

'' fbc 1.05.0 target win32 -gen gcc
'' 2.o:fake:(.text+0x97): undefined reference to `A@4'
'' 2.o:fake:(.text+0x110): undefined reference to `B@4'

As far as I know -gen gas is correct in this case; I checked it against g++ and msvc behaviour a while ago: [4346f9]

gcc only sees an FBSTRING * or complextype * and uses the pointer size. fbc already has support for working around such problems (see hNeedAlias() and hGetMangledNameForASM in ir-hlc.bas), it probably needs to be enabled for all functions with non-trivial byval parameters (or just all functions).

Related

Bugs: #828
Bugs: #888
Commit: [4346f9]

Discussion

  • dkl

    dkl - 2018-07-18
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    --gen gcc gives different @N stdcall suffix than -gen gas:
    +-gen gcc gives different @N stdcall suffix than -gen gas for procedures with non-trivial byval parameters:
     ```
     type complextype
        bigdata(0 to 1000-1) as byte
    @@ -25,4 +25,6 @@
     '' 2.o:fake:(.text+0x110): undefined reference to `B@4'
     ```
    
    +As far as I know -gen gas is correct in this case; I checked it against g++ and msvc behaviour a while ago: [4346f9]
    +
     gcc only sees an `FBSTRING *` or `complextype *` and uses the pointer size. fbc already has support for working around such problems (see `hNeedAlias()` and `hGetMangledNameForASM` in ir-hlc.bas), it probably needs to be enabled for all functions with non-trivial byval parameters (or just all functions).
    
     

    Related

    Commit: [4346f9]

  • Jeff Marshall

    Jeff Marshall - 2018-09-26
    • labels: --> mangling
     
  • Jeff Marshall

    Jeff Marshall - 2018-09-26

    Fixed in commit [d249ff]

     

    Related

    Commit: [d249ff]

  • Jeff Marshall

    Jeff Marshall - 2018-09-26
    • status: open --> closed
     

Log in to post a comment.