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

Native uint doesn't overflow on ++ #4989

Closed
p6rt opened this issue Jan 3, 2016 · 12 comments
Closed

Native uint doesn't overflow on ++ #4989

p6rt opened this issue Jan 3, 2016 · 12 comments

Comments

@p6rt
Copy link

p6rt commented Jan 3, 2016

Migrated from rt.perl.org#127144 (status was 'resolved')

Searchable as RT127144$

@p6rt
Copy link
Author

p6rt commented Jan 3, 2016

From @Juerd

Bug​:

  > my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
  255 -> 0

Work as expected​:

  > my uint8 $x = 256; say $x
  0
  > my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
  255 -> 0
  > my int8 $x = 127; print $x, " -> "; $x++; say $x;
  127 -> -128

I'd like to contribute tests for this; where in roast should I put them?
Please suggest a filename :-)
--
Met vriendelijke groet, // Kind regards, // Korajn salutojn,

Juerd Waalboer <juerd@​tnx.nl>
TNX

@p6rt
Copy link
Author

p6rt commented Jan 3, 2016

From @skids

S02-types/native.t would seem a ood place for testing scalar sized uints.

A couple blocks below the tests for 124084 are some comparable tests.

@p6rt
Copy link
Author

p6rt commented Jan 3, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 4, 2016

From @Juerd

Juerd Waalboer skribis 2016-01-04 0​:25 (+0100)​:

Bug​:
> my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
255 -> 0

Ahem, that's not the bug. This is​:

  > my uint8 $x = 255; print $x, " -> "; $x++; say $x;
  255 -> 256
--
Met vriendelijke groet, // Kind regards, // Korajn salutojn,

Juerd Waalboer <juerd@​tnx.nl>
TNX

@p6rt
Copy link
Author

p6rt commented Jan 4, 2016

From @Juerd

Brian S. Julin via RT skribis 2016-01-03 15​:37 (-0800)​:

S02-types/native.t would seem a ood place for testing scalar sized uints.

Thanks. Unfortunately, I couldn't easily figure out how to write TODO
tests. So here's something that someone could copy and paste​:

  # RT #​127144, uint increment in sink context
  {
  sub d { "++ on uint$^n overflows to 0 in sink context" }
  my uint8 $uint8 = 0xff; $uint8++; is($uint8, 0, d 8);
  my uint16 $uint16 = 0xffff; $uint16++; is($uint16, 0, d 16);
  my uint32 $uint32 = 0xffffffff; $uint32++; is($uint32, 0, d 32);
  my uint64 $uint64 = 0xffffffffffffffff; $uint64++; is($uint64, 0, d 64);
  }
--
Met vriendelijke groet, // Kind regards, // Korajn salutojn,

Juerd Waalboer <juerd@​tnx.nl>
TNX

@p6rt
Copy link
Author

p6rt commented Jan 4, 2016

From @lizmat

On 04 Jan 2016, at 00​:25, Juerd Waalboer (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Juerd Waalboer
# Please include the string​: [perl #​127144]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127144 >

Bug​:

my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
255 -> 0

Work as expected​:

my uint8 $x = 256; say $x
0
my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
255 -> 0
my int8 $x = 127; print $x, " -> "; $x++; say $x;
127 -> -128

I'd like to contribute tests for this; where in roast should I put them?
Please suggest a filename :-)

t/spec/S02-types/native.t probably.

Liz

@p6rt
Copy link
Author

p6rt commented Jan 4, 2016

From @bdw

Just speculating, but I think this can be fixed by codegen; to be specific,
the inc_i op should be followed by a truncate in case of a sized variable.

2016-01-04 11​:37 GMT+01​:00 Elizabeth Mattijsen <liz@​dijkmat.nl>​:

On 04 Jan 2016, at 00​:25, Juerd Waalboer (via RT) <
perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Juerd Waalboer
# Please include the string​: [perl #​127144]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127144 >

Bug​:

my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
255 -> 0

Work as expected​:

my uint8 $x = 256; say $x
0
my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
255 -> 0
my int8 $x = 127; print $x, " -> "; $x++; say $x;
127 -> -128

I'd like to contribute tests for this; where in roast should I put them?
Please suggest a filename :-)

t/spec/S02-types/native.t probably.

Liz

@p6rt
Copy link
Author

p6rt commented Jan 4, 2016

From @lizmat

On 04 Jan 2016, at 00​:25, Juerd Waalboer (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Juerd Waalboer
# Please include the string​: [perl #​127144]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127144 >

Bug​:

my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
255 -> 0

What is the bug here??? Looks to me it’s entirely doing what is expected?

Liz

@p6rt
Copy link
Author

p6rt commented Jan 4, 2016

From @FROGGS

That highlights the bug​:

m​: my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
rakudo-moar 0f26ae​: OUTPUT«255 -> 0␤»

m​: my uint8 $x = 255; print $x, " -> "; $x++; say $x;
rakudo-moar 0f26ae​: OUTPUT«255 -> 256␤»

Am 04.01.2016 um 11​:48 schrieb Elizabeth Mattijsen​:

On 04 Jan 2016, at 00​:25, Juerd Waalboer (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Juerd Waalboer
# Please include the string​: [perl #​127144]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127144 >

Bug​:

my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
255 -> 0
What is the bug here??? Looks to me it’s entirely doing what is expected?

Liz

@p6rt
Copy link
Author

p6rt commented Apr 8, 2017

From @AlexDaniel

This no longer prints 256.

Bisectable points to rakudo/rakudo@5401a1a

Is it actually resolved or not?

I will mark it testneeded for now (if it's not resolved, the tests should reveal it).

On 2016-01-04 04​:14​:49, FROGGS.de wrote​:

That highlights the bug​:

m​: my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
rakudo-moar 0f26ae​: OUTPUT«255 -> 0␤»

m​: my uint8 $x = 255; print $x, " -> "; $x++; say $x;
rakudo-moar 0f26ae​: OUTPUT«255 -> 256␤»

Am 04.01.2016 um 11​:48 schrieb Elizabeth Mattijsen​:

On 04 Jan 2016, at 00​:25, Juerd Waalboer (via RT) <perl6-bugs-
followup@​perl.org> wrote​:

# New Ticket Created by Juerd Waalboer
# Please include the string​: [perl #​127144]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127144 >

Bug​:

my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
255 -> 0
What is the bug here??? Looks to me it’s entirely doing what is
expected?

Liz

@p6rt
Copy link
Author

p6rt commented Jul 22, 2017

From @dogbert17

On Fri, 07 Apr 2017 19​:16​:17 -0700, alex.jakimenko@​gmail.com wrote​:

This no longer prints 256.

Bisectable points to
rakudo/rakudo@5401a1a

Is it actually resolved or not?

I will mark it testneeded for now (if it's not resolved, the tests
should
reveal it).

On 2016-01-04 04​:14​:49, FROGGS.de wrote​:

That highlights the bug​:

m​: my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
rakudo-moar 0f26ae​: OUTPUT«255 -> 0␤»

m​: my uint8 $x = 255; print $x, " -> "; $x++; say $x;
rakudo-moar 0f26ae​: OUTPUT«255 -> 256␤»

Am 04.01.2016 um 11​:48 schrieb Elizabeth Mattijsen​:

On 04 Jan 2016, at 00​:25, Juerd Waalboer (via RT) <perl6-bugs-
followup@​perl.org> wrote​:

# New Ticket Created by Juerd Waalboer
# Please include the string​: [perl #​127144]
# in the subject line of all future correspondence about this
issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127144 >

Bug​:

my uint8 $x = 255; print $x, " -> "; $x = $x + 1; say $x;
255 -> 0
What is the bug here??? Looks to me it’s entirely doing what is
expected?

Liz

Turns out the the tests listed above where added to roast with
Raku/roast@c824a98
Closing issue

@p6rt
Copy link
Author

p6rt commented Jul 22, 2017

@dogbert17 - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jul 22, 2017
@p6rt p6rt added the testneeded label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant