You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In C++ initialization of an enum class should value initialize (at least in the case of an empty initializer list, I haven't dug too deeply into what should happen if given a real value). Cython compiles such code but then throws a NameError at runtime.
Code to reproduce the behaviour:
# distutils: language = c++
cdef enumclass my_enum(int):
a =1
b =2deff():
my_enum()
This code compiles correctly, but at runtime I get:
(main) dt08% python -c 'import definitions; definitions.f()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "definitions.pyx", line 10, in definitions.f
my_enum()
NameError: name 'my_enum' is not defined
Expected behaviour
I think throwing an error during compilation would be an acceptable outcome here, if normal value initialization is not possible (especially if the non-empty initializer list case is actually UB; I haven't looked deeply enough yet to say either way).
OS
Linux
Python version
3.11.4
Cython version
3.0.0
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
In C++ initialization of an enum class should value initialize (at least in the case of an empty initializer list, I haven't dug too deeply into what should happen if given a real value). Cython compiles such code but then throws a NameError at runtime.
Code to reproduce the behaviour:
This code compiles correctly, but at runtime I get:
Expected behaviour
I think throwing an error during compilation would be an acceptable outcome here, if normal value initialization is not possible (especially if the non-empty initializer list case is actually UB; I haven't looked deeply enough yet to say either way).
OS
Linux
Python version
3.11.4
Cython version
3.0.0
Additional context
No response
The text was updated successfully, but these errors were encountered: