Skip to content

simd_shuffle error message uses dest_len (output) instead of left_len (input), reporting wrong valid range #494

@SebTardif

Description

@SebTardif

Summary

In compiler/rustc_const_eval/src/interpret/intrinsics/simd.rs, both simd_shuffle and simd_shuffle_const_generic error messages report the output vector length (dest_len) instead of the input vector length (left_len) when an index is out-of-bounds.

Location

compiler/rustc_const_eval/src/interpret/intrinsics/simd.rs, lines 576 and 605

Bug

The valid index range for simd_shuffle is [0, left_len + right_len) where left_len == right_len (the input vectors). The error message says:

`simd_shuffle` index {src_index} is out-of-bounds for 2 vectors with length {dest_len}

dest_len is the OUTPUT vector length, not each input vector's length. When dest_len != left_len, the message reports the wrong valid range.

Example: If input vectors have 4 elements each (left_len=4) and output has 8 elements (dest_len=8), valid indices are 0..8. The error message says "out-of-bounds for 2 vectors with length 8", suggesting valid range 0..16. The correct message should say "with length 4".

Fix

Replace {dest_len} with {left_len} in both error messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalConst evaluationA-diagnosticsCompiler diagnosticsI-wrongWrong result or data corruptionP-lowLow impact: edge case or niche scenariobugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions