http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47702
Summary: feature request: sentinel_value Product: gcc Version: 4.4.5 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: er...@gcc.gnu.org __attribute__((sentinel)) is great for detecting a trailing NULL argument. But what about code that wants to detect some other trailing sentinel argument? For example: #include <stdarg.h> enum flags { FLAG_A, FLAG_B, FLAG_C, FLAG_LAST }; void setFlags(int *result, ...) { va_list list; int flag; va_start(list, result); while ((flag = va_arg(list, int)) != FLAG_LAST) *result |= 1 << flag; va_end(list); } int main (void) { int flags; setFlags(flags, FLAG_A, FLAG_C, FLAG_LAST); return flags; } I'd love to be able to mark that all callers of setFlags must provide a trailing argument of FLAG_LAST as their sentinel value. Would it be possible to introduce: __attribute__((sentinel_value(value, [position]))) and make the current sentinel([position]) be strictly equivalent to sentinel_value(NULL, [position]).