Issue 23799 - Link error with -betterC
Summary: Link error with -betterC
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2023-03-22 16:29 UTC by SHOO
Modified: 2023-04-01 22:15 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description SHOO 2023-03-22 16:29:50 UTC
In the dmd.2.103.0-rc.1, the following code causes a link error when built with the -betterC compile option:
-----------------
struct Data
{
	Data[] range;
	string test;
}

Data[] foo()
{
	Data[] ret;
	if (__ctfe)
	{
		Data tmp;
		tmp.range ~= Data.init;
		ret ~= tmp;
	}
	return ret;
}

void func(Data dat)()
{
}

void bar(Data dat)()
{
	if (dat.test.length)
		func!(dat.range[0])();
}

extern (C) void main()
{
	static immutable data = foo();
	bar!(data[0])();
}
-----------------

$ dmd -betterC main.d
/usr/bin/ld: main.o: in function `main':
main.d:(.text.main[main]+0x5): undefined reference to `_D4main__T3barVSQo4DataS2A1S2nnnZQxFNaNbNiNfZv'
collect2: error: ld returned 1 exit status
Comment 1 Dlang Bot 2023-03-23 09:49:47 UTC
@RazvanN7 created dlang/dmd pull request #15028 "Fix Issue 23799 - Link error with -betterC" fixing this issue:

- Fix Issue 23799 - Link error with -betterC

https://github.com/dlang/dmd/pull/15028
Comment 2 Dlang Bot 2023-03-23 12:04:32 UTC
dlang/dmd pull request #15028 "Fix Issue 23799 - Link error with -betterC" was merged into stable:

- 7c3e49b0d5ae05c668e198b47ff58721e3dd419e by RazvanN7:
  Fix Issue 23799 - Link error with -betterC

https://github.com/dlang/dmd/pull/15028
Comment 3 Dlang Bot 2023-04-01 22:15:16 UTC
dlang/dmd pull request #15066 "merge stable" was merged into master:

- d46295483ac60dc01e8fac456e407eacda36c12f by Razvan Nitu:
  Fix Issue 23799 - Link error with -betterC (#15028)

https://github.com/dlang/dmd/pull/15066