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 22970 - importC: taking address one past array end gives bo… #13945

Merged
merged 1 commit into from
Apr 5, 2022

Conversation

WalterBright
Copy link
Member

…unds error

@WalterBright WalterBright added the Feature:ImportC Pertaining to ImportC support label Apr 4, 2022
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Auto-close Bugzilla Severity Description
22970 normal importC: taking address one past array end gives bounds error

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#13945"

@WalterBright WalterBright force-pushed the fix22970 branch 3 times, most recently from 2bf5574 to 83ac8ab Compare April 4, 2022 08:23
*/
if (!(dim == 0 && ve.var.isCsymbol()))
if (!((dim == 0 || dim == index) && ve.var.isCsymbol()))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why address +1 past the end of the buffer is ok, but 2 isn't.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Because:

int x[4];
for (p = &x[0]; p < &x[4]; ++p)

is a common pattern. x[4] is never dereferenced.

@WalterBright
Copy link
Member Author

The buildkite failure is some networking failure.

@RazvanN7 RazvanN7 merged commit 93907a5 into dlang:master Apr 5, 2022
@WalterBright WalterBright deleted the fix22970 branch April 5, 2022 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ImportC Pertaining to ImportC support Severity:Bug Fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants