Skip to content

Something wrong with integer type #7992

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

Closed
yurasin opened this issue Sep 14, 2018 · 1 comment
Closed

Something wrong with integer type #7992

yurasin opened this issue Sep 14, 2018 · 1 comment
Labels
Type: Duplicate Another item already exists for this topic

Comments

@yurasin
Copy link

yurasin commented Sep 14, 2018

Compiling integer varies from previous IDE version
In 1.8.6 it seems to be bad, not in range -32768..+32768
At least when compiled to Arduino Nano.

Simplest check:
void setup() {
Serial.begin(115200);
}
void loop() {
for (int i = 30000;; i++) Serial.println(i);
}

And another check with even more strange behavior:
void setup() {
Serial.begin(115200);
}
void loop() {
for (int i = 33000;; i++) Serial.println(i);
}

In version 1.6.5 everything OK.

@per1234
Copy link
Collaborator

per1234 commented Sep 14, 2018

Closing as duplicate of #4511

Signed integer overflow is undefined behavior. You can't rely on any specific results.

There is a proposal that would make it behave as you expect: #4624

@per1234 per1234 closed this as completed Sep 14, 2018
@per1234 per1234 added the Type: Duplicate Another item already exists for this topic label Sep 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Duplicate Another item already exists for this topic
Projects
None yet
Development

No branches or pull requests

2 participants