Skip to content

cgen behaviour for importc objects using importc objects internally #1419

Closed
@shayanhabibi

Description

@shayanhabibi

Example

I have spent a bit of time debugging this today.
I admit this might be incorrect by our specifications, so I wanted to check and otherwise report it.

type
  int128 {.importc: "__int128".} = object
    `✀`, `✂` : uint64 # These fields are inaccessible
  hint128 = object
    x*,y*: uint

{.push, header: "<stdatomic.h>".}

type
  AtomicInt8* {.importc: "_Atomic NI8".} = int8
  AtomicInt16* {.importc: "_Atomic NI16".} = int16
  AtomicInt32* {.importc: "_Atomic NI32".} = int32
  AtomicInt64* {.importc: "_Atomic NI64".} = int64
  AtomicInt128* {.importc: "_Atomic __int128".} = int128 # INVALID compilation for use in 128bit atomicops

Please note the last line.
When performing generic procedures which would use this type, the codegen would generate a struct instead of an alias for type int128 {.importc: "__int128".} = object #....

If however it is changed to AtomicInt128* {.importc: "_Atomic __int128".} = hint128 then I do not have any issues. Is this intended? If so, perhaps causing such a type decl as an error would be helpful ~

type
  AtomicInt8* {.importc: "_Atomic NI8".} = int8
  AtomicInt16* {.importc: "_Atomic NI16".} = int16
  AtomicInt32* {.importc: "_Atomic NI32".} = int32
  AtomicInt64* {.importc: "_Atomic NI64".} = int64
  # AtomicInt128* {.importc: "_Atomic __int128".} = int128 # INVALID compilation for use in 128bit atomicops
  AtomicInt128*{.importc: "_Atomic __int128".} = hint128 # <- works

If this is borne from ignorance, please forgive me!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompiler/backendRelated to backend system of the compilerduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions