[libc-commits] [PATCH] D71094: [libc] Add implementation of errno and define the other macros of errno.h.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Dec 6 11:47:44 PST 2019


sivachandra added a comment.

In D71094#1773028 <https://reviews.llvm.org/D71094#1773028>, @MaskRay wrote:

> For posterity, `#define errno *__errno_location()` breaks C11 7.1.2p5:
>
> > Any definition of an object-like macro described in this clause shall expand to code that is fully protected by parentheses where necessary, so that it groups in an arbitrary expression as if it were a single identifier.
>
> It will fail to diagnose code like `3 errno[0]` (false positive), and incorrectly flag (false negative):
>
>   const char *blah[] = { [EILSEQ] = "asdf" };
>   errno = EILSEQ;
>   puts(errno[blah]);
>   
>
> and `errno++`


FWIW, I had accepted your suggestion before you made this comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71094/new/

https://reviews.llvm.org/D71094





More information about the libc-commits mailing list