[clang] [clang][analyzer] Add C standard streams to the internal memory space (PR #147766)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 10 07:52:32 PDT 2025
=?utf-8?q?Balázs_Kéri?= <balazs.keri at ericsson.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/147766 at github.com>
steakhal wrote:
> > BTW wouldn't this patch break the semantics of `freopen`? That one should invalidate the file ptr, right? Could you demonstrate this?
>
> No, `freopen` should _not_ invalidate the file _ptr_, because it modifies the stream object (associating it with a different file) _without_ changing the pointer identity of the stream object. In fact, if you consider the signature, you can see that in
>
> ```c
> FILE *freopen(const char *pathname, const char *mode, FILE *stream);
> ```
>
> the third parameter takes an _rvalue_ of type `FILE *`, so if you call e.g. `freopen("somefile.txt", "r", stdin)` then this cannot invalidate the `FILE *` pointer stored in the global variable `stdin`.
makes sense, thx
https://github.com/llvm/llvm-project/pull/147766
More information about the cfe-commits
mailing list