Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation Failure - empty scalar initializer - Inheritable objects & Atomics [OA]RC on DEVEL #18844

Closed
shayanhabibi opened this issue Sep 13, 2021 · 2 comments · Fixed by #18851

Comments

@shayanhabibi
Copy link

shayanhabibi commented Sep 13, 2021

The following fails to compile with the listed error using ARC or ORC however compiles successfully on REFC

import atomics

type
  # Deprivation* = ref object of RootObj    # compiles
  Deprivation* = object of RootObj        # fails
    memes*: Atomic[int]
  Zoomer = object
    dopamine: Deprivation                 # fails
    # dopamine: ref Deprivation             # compiles

# discard Deprivation()                     # compiles
discard Zoomer()                          # fails

I have tagged which lines I have narrowed down to causing issues and what doesn't.

This was found while trying to use elijahrs lockfreequeue types as fields of objects.

C:\Users\PC\nimcache\cpsloop_r\@mcpsloop.nim.c:199:132: error: empty scalar initializer
 static NIM_CONST tyObject_Zoomer__yhOZMQHEaznD9aq8IQHJaMQ TM__8CKjD9bWE6mTvTNPLW3KYWw_2 = {{{(&NTIv2__DdWjNMQNgJ9aHiVjMo4gjYw_)}, {{}}}}

                        ^
C:\Users\PC\nimcache\cpsloop_r\@mcpsloop.nim.c:199:132: note: (near initialization for 'TM__8CKjD9bWE6mTvTNPLW3KYWw_2.dopamine.memes.value')
Error: execution of an external compiler program 'gcc.exe -c  -w -fmax-errors=3 -mno-ms-bitfields -O3 -fno-strict-aliasing -fno-ident   -IC:\Users\PC\.choosenim\toolchains\nim-#devel\lib -Ic:\Users\PC\Documents\Programming\ParthianProject\Modules\cps_minfosclient\cpsbridge -o C:\Users\PC\nimcache\cpsloop_r\@mcpsloop.nim.c.o C:\Users\PC\nimcache\cpsloop_r\@mcpsloop.nim.c' failed with exit code: 1
@ringabout
Copy link
Member

ringabout commented Sep 13, 2021

Related: #18410

C++ backend can be fixed using -std=gnu++17

I'll push a fix after #18836 is merged or solved.

@metagn
Copy link
Collaborator

metagn commented May 10, 2023

This is not fixed, or at least it's not tested (this test also does not run for c++ at all). -std=gnu++17 does not seem to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants