Open haxscramper opened 3 years ago
It seems to be a regression. Works in 1.2.x
I didn't bother to run a git bisect, but I skimmed all commits between 1.4.0 and 1.2.0. Fortunately I find the culprit at the second guess => https://github.com/nim-lang/Nim/pull/14161
@github-actions nim cpp
type Base* = ref object of RootObj
method printSpace(c: var Base): void = discard
type Derived = ref object of Base
method printSpace(c: var Derived) = discard
@juancarlospaco Hi, do you happen to know why the CI wasn't finished?
@ringabout The bug is a codegen bug, is generating:
error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___QicCB7GN6dWokpZFgUI4JA*&’
183 | printSpace__qGJls9cgdB4kneGWilyN1tg((*((tyObject_DerivedcolonObjectType___QicCB7GN6dWokpZFgUI4JA*&*) (&(c)))));
| ^
Error: execution of an external compiler program 'g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -I/home/runner/.choosenim/toolchains/nim-1.4.0/lib -I/home/runner/work/nimrun-action-minefield/nimrun-action-minefield -o /home/runner/work/nimrun-action-minefield/nimrun-action-minefield/@mtemp.nim.cpp.o /home/runner/work/nimrun-action-minefield/nimrun-action-minefield/@mtemp.nim.cpp' failed with exit code: 1
it is the line:
printSpace__qGJls9cgdB4kneGWilyN1tg((*((tyObject_DerivedcolonObjectType___QicCB7GN6dWokpZFgUI4JA*&*) (&(c)))));
and complaining on the *&*
The bot is failing because that sample is crashing all compilers from devel to 1.0 (older than 1.0 lang becomes too weird to bisect, strings and seqs are nil etc).
It needs at least 2 commits, 1 working, 1 non-working, then bisects between that range of commits until finds the breaking commit.
Basically that sample never worked properly in Nim.
That needs to be fixed/improved anyway, thanks for the info.
@ringabout This commit introduced the bug: https://github.com/nim-lang/Nim/commit/d6e1b5c07#diff-4509107d295d7d32b1887c8993cd0f56113ae60f36113e7d8778646dabd92ebcR2475
!nim cpp
type Base* = ref object of RootObj
method printSpace(c: var Base): void = discard
type Derived = ref object of Base
method printSpace(c: var Derived) = discard
@ringabout (member)devel :-1: FAIL
Output
Error: Command failed: nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/@mtemp.nim.cpp: In function ‘void printSpace__temp_u5(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg*&)’:
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:114:100: error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*&’
114 | printSpace__temp_u8((*((tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*&*) (&(c_p0)))));
| ^
Error: execution of an external compiler program 'g++ -c -std=gnu++17 -funsigned-char -w -fmax-errors=3 -fpermissive -I'/home/runner/.choosenim/toolchains/nim-#devel/lib' -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.cpp.o /home/runner/work/Nim/Nim/@mtemp.nim.cpp' failed with exit code: 1
2023-07-05T00:31:37Z
2023-07-05T00:32:13
2023-07-05T00:32:14
1 minute
nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
Error: Command failed: nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/@mtemp.nim.cpp: In function ‘void printSpace__temp_5(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg*&)’:
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:162:99: error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*&’
162 | printSpace__temp_8((*((tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*&*) (&(c)))));
| ^
Error: execution of an external compiler program 'g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -I/home/runner/.choosenim/toolchains/nim-1.6.14/lib -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.cpp.o /home/runner/work/Nim/Nim/@mtemp.nim.cpp' failed with exit code: 1
2023-07-05T00:31:37Z
2023-07-05T00:32:14
2023-07-05T00:32:15
1 minute
nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
Error: Command failed: nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/@mtemp.nim.cpp: In function ‘void printSpace_temp_5(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g*&)’:
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:162:99: error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*&’
162 | printSpace_temp_8((*((tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*&*) (&(c)))));
| ^
Error: execution of an external compiler program 'g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -I/home/runner/.choosenim/toolchains/nim-1.6.0/lib -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.cpp.o /home/runner/work/Nim/Nim/@mtemp.nim.cpp' failed with exit code: 1
2023-07-05T00:31:37Z
2023-07-05T00:32:18
2023-07-05T00:32:18
1 minute
nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
Error: Command failed: nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/@mtemp.nim.cpp: In function ‘void printSpace__mkDNWpD0kIVP6f1gvo9cg4Q(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g*&)’:
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:180:117: error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*&’
180 | printSpace__K9cIARQqQ3ijlHRnYAjBnKg((*((tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*&*) (&(c)))));
| ^
Error: execution of an external compiler program 'g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -I/home/runner/.choosenim/toolchains/nim-1.4.0/lib -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.cpp.o /home/runner/work/Nim/Nim/@mtemp.nim.cpp' failed with exit code: 1
2023-07-05T00:31:37Z
2023-07-05T00:32:21
2023-07-05T00:32:22
1 minute
nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
2023-07-05T00:31:37Z
2023-07-05T00:32:38
2023-07-05T00:32:38
1 minute
nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
2023-07-05T00:31:37Z
2023-07-05T00:32:52
2023-07-05T00:32:52
1 minute
nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
Clyybber introduced a bug at 2020-04-30 02:01:07 +0200
on commit #d6e1b5c07 with message:
Fix #14160 (#14161)
* Fix #14160
* Add testcase
The bug is in the files:
compiler/ccgexprs.nim
tests/ccgbugs/t14160.nim
The bug can be in the commits:
(Diagnostics sometimes off-by-one).
22 minutes
bisecting 4373
commits at 198
commits per second. @juancarlospaco Hello, would you mind introducing this super neat feature on the forum so that others can learn its existence?
Compiling derived
var
object onC++
backend results in compilation error. No problems onC
backend.Example
Current Output
Compiling code snippet above procedes normally on C backend, but fails on C++ compilation stage with following error:
Expected Output
No compilation error for C++ backend
Possible Solution
Offending cast is generated in
ccgtypes/getTypeDescAux()
.https://github.com/nim-lang/Nim/blob/14c61ecf24110f3f6a1a4a9c88439e568065ddd9/compiler/ccgtypes.nim#L721
I couldn't figure out how to correctly fix this - simply removing
cpp
check obviously breaks a lot of other parts in compilation. If someone has any ideas on fixing this I will try looking into this myself.Generated calls for C++ backend differ only in
&
usedc backend
cpp backend
Additional Information
I'g getting identical error when using
cligen
on CPP backend - I could not minimize it due to lots of macro-generated code, butalso fails. I'm not entirely sure if this is related, but it gives the same error message under the same conditions (
C++
dies,C
ok)