Your message dated Mon, 29 Jun 2026 20:30:32 +0000
with message-id <[email protected]>
and subject line Re: cppcheck: Syntax error on func(&data)[0] valid C code
has caused the Debian Bug report #1076061,
regarding cppcheck: Syntax error on func(&data)[0] valid C code
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1076061: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1076061
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: cppcheck
Version: 2.14.0-1
Severity: important

Hi!

I just stumbled over the following issue after some code changes in
dpkg, which is currently failing one of its CI (the one in salsa)
due to this, but I'll modify the involved code to avoid this though.

It seems cppcheck does not handle correctly dereferencing a pointer
returned by a function, when said function gets passed a pointer by
reference.

Here's the smallest reproducer I could concoct:

  ,--- deref-return.c
  const char *func(int *data) {
          return "some string" + *data;
  }
  int main() {
          int data = 2;
          int *pdata = &data;
          if (func(&data)[0] == 'm')
                  return 0;
          return 1;
  }
  `---

  ,--- shell
  $ cppcheck deref-return.c
  Checking deref-return.c ...
  deref-return.c:7:12: error: Code '(& data' is invalid C code. Use --std or 
--language to configure the language. [syntaxError]
   if (func(&data)[0] == 'm')
             ^
  `---

If I change the call to «ref(pdata)[0]», then cppcheck is happy with
that.

Thanks,
Guillem

--- End Message ---
--- Begin Message ---
Version: 2.15.0-1

This has been fixed upstream quite a while ago but somehow slipped through the cracks.

Best regards,
  Joachim

--- End Message ---

Reply via email to