Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 7997 - Optlink issues 'Index Range' error with static zero … #7243

Merged
merged 1 commit into from
Oct 26, 2017

Conversation

WalterBright
Copy link
Member

…length array

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Auto-close Bugzilla Description
7997 Optlink issues 'Index Range' error with static zero length array

{
/* Give it a byte of data
* so we can take the 'address' of this symbol
* and avoid problematic behavior of object file format
Copy link
Contributor

@skl131313 skl131313 Oct 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid problematic behavior of object file format

Isn't this more Optlink incorrectly handling the object file format than an error in the object file format. A patch should be made to fix Optlink instead of creating a workaround for it here, with a vague comment that doesn't mention what it actually is: an Optlink bug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optlink is much more difficult to look into so I'll take this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar problems happen with other object file formats.

I'm not sure one could call it a 'bug' in the file format anyway. What does it mean to take the address of a 0 length object? Should the object file format decide that?

A similar thing happens with empty C++ structs:

struct S { };
S* p = new S();

What happens? Weird problems can arise, so the standard devised a simple solution - it gives it a size of 1. The problems go away.

Copy link
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the coverage issues are not unexpected.

@andralex andralex merged commit 4a62e84 into dlang:master Oct 26, 2017
@WalterBright WalterBright deleted the fix7997 branch October 26, 2017 18:50
@WalterBright
Copy link
Member Author

Coverage testing is done on Linux, so OSX specific code isn't covered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants