|
|
Message-Id: <200A820C-D33B-4A1D-BC8B-8E4AAA46C50F@eleanor-nb.com>
Date: Fri, 30 Jan 2026 20:55:31 +1100
From: Eleanor Bartle <eleanor@...anor-nb.com>
To: musl@...ts.openwall.com
Subject: New C Qualifier Idea
Hello. I had an idea for a new C type qualifier for a future standard, but don’t know where to share it for feedback. Apologies if this is the wrong place.
The qualifier is 'confine', and it would work as follows:
confine char *postfix (confine char *str, uintptr_t from) {
// ERROR: shared outside function
// global_var = str;
// OK: returned to caller
return *str[from];
}
// ...
char *post = postfix(str, 10);
// ERROR: returned from function
return post;
The 'confine' qualifier annotates pointers to stack-allocated values in higher scopes. it would prevent these values from being shared outside the function, but not from being returned from the function; a returned 'confine' pointer behaves as a pointer to local in the calling scope, i.e. returning or saving it becomes a detectable error.
Ideally the sense would be inverted, i.e. there would be a 'permit' qualifier that denotes the opposite meaning and no qualifier would mean 'confine', but that horse has long since bolted.
Prior art is D's 'scope' and 'return scope' qualifiers, and Zig once entertained the idea under the name 'nocopy'.
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.