google / google/xls

std::sizeof is not considered constexpr

Open
#1,732 1 comment 0 reactions 0 assignees View on GitHub
dslx
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

std::sizeof is not considered a compile time constant even though the value is known at compile time.

Repro:

```rust
import std;

fn foo(x: u32, z:u8) -> u8 {
x[0:std::sizeof(z)]
}
```

Error:

```
std_size_not_const.x:4:20-4:23
0002:
0003: fn foo(x: u32, z:u8) -> u8 {
0004: x[0:std::sizeof(z)]
~~~~~~~~~~~~~~~~~~~~~~~~~^-^ TypeInferenceError: Unable to resolve slice limit to a compile-time constant.
0005: }
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.