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

errors for large left shifts #4882

Open
p6rt opened this issue Dec 17, 2015 · 4 comments
Open

errors for large left shifts #4882

p6rt opened this issue Dec 17, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 17, 2015

Migrated from rt.perl.org#126943 (status was 'open')

Searchable as RT126943$

@p6rt
Copy link
Author

p6rt commented Dec 17, 2015

From zefram@fysh.org

When shifting a non-zero integer left by a very large amount, generally
some kind of error should result, such as memory exhaustion. But for
some values Rakudo is producing silly small outputs​:

123 +< (1 +< 31)
8863084066665136128
123 +< ((1 +< 31) + 1)
17726168133330272256
123 +< ((1 +< 32) - 1)
0
123 +< (1 +< 32)
123
123 +< ((1 +< 32) + 1)
246
123 +< ((1 +< 33) - 1)
0
123 +< (1 +< 33)
123
123 +< ((1 +< 33) + 1)
246
123 +< ((1 +< 64) - 1)
61

-zefram

@p6rt
Copy link
Author

p6rt commented Dec 17, 2015

From @lizmat

On 17 Dec 2015, at 03​:48, Zefram (via RT) <perl6-bugs-followup@​perl.org> wrote​:

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

When shifting a non-zero integer left by a very large amount, generally
some kind of error should result, such as memory exhaustion. But for
some values Rakudo is producing silly small outputs​:

123 +< (1 +< 31)
8863084066665136128
123 +< ((1 +< 31) + 1)
17726168133330272256
123 +< ((1 +< 32) - 1)
0
123 +< (1 +< 32)
123
123 +< ((1 +< 32) + 1)
246
123 +< ((1 +< 33) - 1)
0
123 +< (1 +< 33)
123
123 +< ((1 +< 33) + 1)
246
123 +< ((1 +< 64) - 1)
61

As with #​126941, commit f6091476486d29c8886d gives this a slightly better error message, at least until 6.c.

$ 6 'say 123 +< ((1 +< 32) - 1)'
Big integer 4294967295 not yet supported on righthand side of '+<' operator

Liz

@p6rt
Copy link
Author

p6rt commented Dec 17, 2015

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

@p6rt
Copy link
Author

p6rt commented Dec 17, 2015

From zefram@fysh.org

Elizabeth Mattijsen via RT wrote​:

As with #​126941, commit f6091476486d29c8886d gives this a slightly
better error message, at least until 6.c.

Providing any error here, rather than a wrong answer, resolves this issue.
At least it does so for the cases with a non-zero lhs, for which the
correct answer can't be represented.

In the exception where the lhs is zero, formerly shift distances up to
((1 +< 64) - 1) were accepted, and it's a shame to reduce that range.
But either way that range being limited is LTA in a manner exactly akin
to [perl #​126941]. That ought to be addressed as an extension of that
ticket or as a separate issue.

Since you've raised the question of pre-xmas vs post-xmas, I think the
only one of these bit-shift tickets that could possibly be a pre-xmas
priority is [perl #​126942]. Not because it has any deep implications,
but just because the lower end of its misbehaviour is reachable with
reasonable inputs that are fairly likely to arise in substantive programs.

-zefram

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant