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

Handle size_t and its signed variant #248

Open
sheaf opened this issue Oct 30, 2024 · 2 comments
Open

Handle size_t and its signed variant #248

sheaf opened this issue Oct 30, 2024 · 2 comments

Comments

@sheaf
Copy link
Collaborator

sheaf commented Oct 30, 2024

The C standard specifies (C++23 extension) that integer literals may use the z or Z suffixes, corresponding with the size_t type or its signed version. We currently don't (re)parse such literals (in macros). The unsigned variant has a corresponding Haskell type, CSize, but its signed variant does not.

@TravisCardwell
Copy link
Collaborator

Checking the latest publicly available WD of C23 (n3301, 2024-07-28), the grammar for integer constants is defined on pages 58 through 61 (PDF pages 73 through 76). It does not look like size_t z/Z suffixes are allowed.

A quick test indeed gives an error.

#include <stddef.h>

int main() {
    size_t n = 41z;
    return 0;
}
$ clang -std=c23 sizet.c -o sizet
sizet.c:4:16: error: 'size_t' suffix for literals is a C++23 feature
    4 |     size_t n = 41z;
      |                ^
1 error generated.

@edsko
Copy link
Collaborator

edsko commented Dec 20, 2024

Since it seems the suffix is C++ only (for now), moving this to milestone 4, and marking as low priority.

@edsko edsko added this to the 4: Additional features milestone Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants