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

[SR-743] When Developing a UnsignedIntegerType Larger Than 64 Bits, 64+ Left Shifts Won't Compile with Optimizations #43358

Open
swift-ci opened this issue Feb 15, 2016 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-743
Radar None
Original Reporter jitsusama (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 7.2.1
OS X 10.11.2

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 7f0ac12a312a3180f646410488c31fe9

relates to:

  • SR-847 Swift support for UInt128
  • SR-6749 Describing the "masking shift" operations in terms of bit-masks is not always correct

Issue Description:

Summary:
When creating an UnsignedIntegerType conforming data type, the compiler's optimization check methods are causing the compile to fail even though the conforming type handles all truncation possibilities. If I stage my shifts, it works fine. As in 'let variable: UInt128 = (1 << 63) << 1' works, though 'let variable: UInt128 = 1 << 64' does not.

Steps to Reproduce:

  1. Create a new OS X command line project and copy the contents of the attached main.swift over the templated main.swift.
  2. Edit the scheme for run to be release instead of debug.
  3. With line 820 uncommented, "Shift amount is greater than or equal to type size in bits" error will happen during compiling. With it commented, there is no error.

Expected Results:
Line 820 should work. My <<(:🙂 operator correctly handles the rhs == 64 case by preventing a bit shift on the underlying UInt64 type by 64 bits. It's a completely safe operation.

Actual Results:
I get a "Shift amount is greater than or equal to type size in bits" error on my init(_builtinIntegerLiteral value: _MaxBuiltinIntegerType) initializer when it tries to convert the integer literal.

Configuration:
This only occurs on a release build. Debug builds have no issue.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant