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 sets for architectures with default integers smaller than 32 bits #15258

Merged
merged 1 commit into from
Sep 2, 2020

Conversation

PMunch
Copy link
Contributor

@PMunch PMunch commented Sep 2, 2020

As discussed on IRC I recently discovered that sets didn't work properly on Arduino boards. Something as simple as this would fail:

var mySet: set[0..20]
mySet.incl 17
if not mySet.contains 17:
  # This branch would get executed, even though 17 is obviously meant to be in the set

The core of the issue turned out to be that AVR har 16-bit default integers, which means that checking for any number larger than 16 in a set small enough to be defined as a regular integer and not an array would fail. This is caused by a left shift on the default sized integer which would silently overflow and use an empty mask to check.

@Araq Araq merged commit 2447601 into nim-lang:devel Sep 2, 2020
narimiran pushed a commit that referenced this pull request Sep 11, 2020
narimiran pushed a commit that referenced this pull request Sep 11, 2020
mildred pushed a commit to mildred/Nim that referenced this pull request Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants