capitalthree
06/18/2021, 9:30 AMfun main(args: Array<String>) {
NumbersByBit.values().forEach {
println("The number ${it.name} is: ${it.number.num}")
}
}
enum class NumbersByBit(val number: NumWrapper) {
bb_b(NumWrapper(6)),
bb_c(bb_b.number),
bb_a(bb_b.number),
}
class NumWrapper(val num: Int) {
operator fun plus(other: NumWrapper) = NumWrapper(num + other.num)
}
So is this a bug? Or are self-referential enums out-of-scope for kotlin native?
Update: Based on above messages, I tried kotlin 1.4.31 and the same error occurs.
When I test the binaries with valgrind, I see an invalid read:
The number bb_c is: 6
==895440== Invalid read of size 4
==895440== at 0x443ED1: Init_and_run_start (in /home/alex/IdeaProjects/NativeError/nativeError.kexe_1.5.10~)
==895440== by 0x4A300B2: (below main) (libc-start.c:308)
==895440== Address 0x8 is not stack'd, malloc'd or (recently) free'd
The invalid read error looks the same when running the kotlin 1.4.31 version.russhwolf
06/18/2021, 1:29 PMcapitalthree
06/18/2021, 7:37 PM