[libav-devel] [PATCH 2/5] avstring: Const correct the return pointers of strstr-like functions
nfxjfg at googlemail.com
Tue Aug 4 15:11:12 CEST 2015
On Mon, 3 Aug 2015 23:46:19 +0200
Luca Barbato <lu_zero at gentoo.org> wrote:
> On 03/08/15 23:14, Martin Storsjö wrote:
> > On Mon, 3 Aug 2015, Luca Barbato wrote:
> >> ---
> >> libavutil/avstring.c | 5 +++--
> >> libavutil/avstring.h | 5 +++--
> >> 2 files changed, 6 insertions(+), 4 deletions(-)
Hm, isn't this an API change? (Same for the following patches.)
It could even cause compilation errors in C++ application code.
> > This breaks const-correctness when using these functions on non-const
> > input data. The standard C functions strstr and similar have the same
> > signature as well, taking const pointers, returning a non-const pointer.
> I guess it is one of those ambiguous cases, shall we suppress the
> warning for this function?
> (right now clang complains and it does break const-correctness if the
> input is const).
This is exactly the reason why trying to be const correct in C is silly.
More information about the libav-devel