Issue 1123: fopen and restrict qualified parameters

Authors: Jay Ghiron
Date: 2026-10-15
Submitted against: C23
Status: Open

Normally, standard library functions only have restrict qualifiers added in cases where it is important. However, there is one exception:

#include <stdio.h>
FILE *fopen(const char * restrict filename, const char * restrict mode);

(C23 7.23.5.3 "The fopen function" paragraph 1.)

These restrict qualifiers are useless, since there is nothing mutable that the pointers can alias with. Note that it is not possible to validly form a pointer into a FILE object before said object exists. Other functions that cannot have mutable aliasing, even those that take the same arguments as fopen do not use restrict qualifiers:

#include <string.h>
int strcmp(const char *s1, const char *s2);

(C23 7.26.4.3 "The strcmp function" paragraph 1.)

Using restrict qualifiers in the declaration of fopen only serves to create confusion about the meaning of restrict qualifiers in function parameters of standard library functions. Perhaps the restrict qualifiers could be interpreted as preventing aliasing with errno, though if that were the intent many more functions should have restrict qualifiers added.

Suggested correction

Replace C23 7.23.5.3 paragraph 1:

#include <stdio.h>
FILE *fopen(const char *filename, const char *mode);

Note: Annex B should be updated to remove the restrict qualifiers too.