Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Florian Stinglmayr <florian.stinglmayr@proton.me>
To: "cocci@inria.fr" <cocci@inria.fr>
Subject: [cocci] Bug: cocci seems to have issues with math expression in struct initialisers
Date: Tue, 18 Mar 2025 11:48:49 +0000	[thread overview]
Message-ID: <Cj-R4IgEgd_zgRLBVFxVy7ffXmhDSmTrxrSQhr83u3Lf9M8N9dEBDK8M_idtO0mGjO480pEeMHrQHH4xWmQn1uSwLUHW-jXSt0mlIy_HiNY=@proton.me> (raw)

Hi,

cocci 1.3 seems to have issues parsing math expressions used in struct initialisers.

Given the following code:

> enum {
>   SYMBOLA,
> };
> #define SYMBOL_WIDTH 100
> rect_t dst = { SYMBOLA * SYMBOL_WIDTH, 0, 0, 0 };

cocci complains about the code around multiplicator in the structure initialiser. If I change the code to:

> enum {
>   SYMBOLA,
> };
> #define SYMBOL_WIDTH 100
> int x = SYMBOLA * SYMBOL_WIDTH;
> rect_t dst = { x, 0, 0, 0 };

Then cocci parses it without error.

Regards
Florian

             reply	other threads:[~2025-03-18 13:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 11:48 Florian Stinglmayr [this message]
2025-03-18 15:43 ` [cocci] Bug: cocci seems to have issues with math expression in struct initialisers Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='Cj-R4IgEgd_zgRLBVFxVy7ffXmhDSmTrxrSQhr83u3Lf9M8N9dEBDK8M_idtO0mGjO480pEeMHrQHH4xWmQn1uSwLUHW-jXSt0mlIy_HiNY=@proton.me' \
    --to=florian.stinglmayr@proton.me \
    --cc=cocci@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).