Hi Alexey,
>The question is why the #include_next directive in syslimits.h results in including <gcc-include-dir>/limits.h, not in including limits.h from the next directory in the search list.
Because <gcc-include-dir>/limits.h is the first one in the search list.
"This directive works like `#include' except in searching for the specified file: it starts searching the list of header file directories _after_ the directory in which the current file was found."
<syslimits.h> is not <limits.h>
The current <limits.h> file for the invocation within <syslimits.h> had not been found yet, so it starts with the first system include search path directory (i.e., <gcc-include-dir>).
HTH, --Eljay