Skip to content

Navigation Menu

Sign in
Appearance settings
Sign up
Appearance settings

Arithmetic on Generic types #503

Copy link
Copy link

Description

@souragc
Issue body actions

Let's say I have the following code.

_For_any(T) void func(_Array_ptr<T> ptr) {
    ptr++;
}

int main() {
    char *ptr;
    func<char>(ptr);
}

Currently Checked C doesn't support arithmetic on generic types:

error: arithmetic on a pointer to an incomplete type 'T' (aka '(0, 0)')
    ptr++;
    ~~~^
1 error generated.

Is there another way we can write it such that we can keep the checked pointer and do arithmetic as well?
Note that this function needs to have generic type.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.