D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22923 - importC: forward-declared static variable has invalid address
Summary: importC: forward-declared static variable has invalid address
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: ImportC, pull, wrong-code
Depends on:
Blocks:
 
Reported: 2022-03-25 11:27 UTC by duser
Modified: 2022-03-31 08:12 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description duser 2022-03-25 11:27:35 UTC
on linux with -fPIC:

static int xs;
int printf(char *, ...);
int main()
{
	printf("%p\n", &xs); // prints 0x1
	int x = xs; // segfaults
	return 0;
}
static int xs = 1;

seems to be the same as issue 22897 but for variables
Comment 1 Dlang Bot 2022-03-31 06:53:36 UTC
@WalterBright created dlang/dmd pull request #13932 "fix Issue 22923 - importC: forward-declared static variable has inval…" fixing this issue:

- fix Issue 22923 - importC: forward-declared static variable has invalid address

https://github.com/dlang/dmd/pull/13932
Comment 2 Dlang Bot 2022-03-31 08:12:10 UTC
dlang/dmd pull request #13932 "fix Issue 22923 - importC: forward-declared static variable has inval…" was merged into master:

- 7748b7e0404af85d0ce6aa5accf4441a6d49af5a by Walter Bright:
  fix Issue 22923 - importC: forward-declared static variable has invalid address

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