Skip to content

internal compiler crash having to do with constant math #201

Closed

Description

@andrewrk
const TINY_QUANTUM_SHIFT = 4;
const TINY_QUANTUM_SIZE = 1 << TINY_QUANTUM_SHIFT;

var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE - 1);
./zig build test.zig --name test --export obj --check-unused

Activity

  1. added
    bugObserved behavior contradicts documented or intended behavior
    on Sep 26, 2016
  2. added this to the 0.1.0 milestone on Sep 26, 2016
  3. pavildon commented on Sep 26, 2016

    @pavildon
    Contributor

    if I define the const variables with explicit types (or casting them) the crash goes away. I think the compiler should just inform you and fail gracefully with an error, since theres no way to imply a type there, and any assumption made can be very dangerous.

  4. andrewrk commented on Sep 26, 2016

    @andrewrk
    MemberAuthor

    That's probably what it's supposed to do. I'll look into this in a bit.

  5. andrewrk commented on Sep 26, 2016

    @andrewrk
    MemberAuthor

    This is fixed now. Problem was failing to make it be a compile error to do the ~ (binary not) operator on an integer literal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions