* [Cocci] perhaps a bug
@ 2018-04-29 12:46 Robert Larice
2018-04-29 12:58 ` Julia Lawall
0 siblings, 1 reply; 8+ messages in thread
From: Robert Larice @ 2018-04-29 12:46 UTC (permalink / raw)
To: cocci
Hello,
attached is a small example which does something strange
to a "int i, j;" within a "#ifdef..."
Perhaps this points to a bug in coccinelle,
Would you please check ?
Best Regards,
Robert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex1.c
Type: text/x-csrc
Size: 122 bytes
Desc: not available
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20180429/e536b96f/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ex1.cocci
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20180429/e536b96f/attachment.ksh>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cocci] perhaps a bug
2018-04-29 12:46 [Cocci] perhaps a bug Robert Larice
@ 2018-04-29 12:58 ` Julia Lawall
2018-04-29 13:06 ` Robert Larice
0 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2018-04-29 12:58 UTC (permalink / raw)
To: cocci
On Sun, 29 Apr 2018, Robert Larice wrote:
> Hello,
>
> attached is a small example which does something strange
> to a "int i, j;" within a "#ifdef..."
> Perhaps this points to a bug in coccinelle,
> Would you please check ?
Thanks for the report. It looks like a bug. But everything is fine if
you removed the --defined BOO.
julia
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cocci] perhaps a bug
2018-04-29 12:58 ` Julia Lawall
@ 2018-04-29 13:06 ` Robert Larice
2018-04-29 13:16 ` Julia Lawall
0 siblings, 1 reply; 8+ messages in thread
From: Robert Larice @ 2018-04-29 13:06 UTC (permalink / raw)
To: cocci
Julia Lawall <julia.lawall@lip6.fr> writes:
> On Sun, 29 Apr 2018, Robert Larice wrote:
>
>> Hello,
>>
>> attached is a small example which does something strange
>> to a "int i, j;" within a "#ifdef..."
>> Perhaps this points to a bug in coccinelle,
>> Would you please check ?
>
> Thanks for the report. It looks like a bug. But everything is fine if
> you removed the --defined BOO.
>
> julia
Yes, in this example it works without this --defined announcement.
I stumbled on this with something more complex, which for some
reason I don't understand yet ignores a wanted transformation
in a #ifdef..#endif, except if I add such a --defined.
Only then it honours my transformation, but fails with this bug.
I certainly will try to work around somehow.
Regards,
Robert
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cocci] perhaps a bug
2018-04-29 13:06 ` Robert Larice
@ 2018-04-29 13:16 ` Julia Lawall
2018-04-29 13:43 ` Robert Larice
0 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2018-04-29 13:16 UTC (permalink / raw)
To: cocci
On Sun, 29 Apr 2018, Robert Larice wrote:
> Julia Lawall <julia.lawall@lip6.fr> writes:
>
> > On Sun, 29 Apr 2018, Robert Larice wrote:
> >
> >> Hello,
> >>
> >> attached is a small example which does something strange
> >> to a "int i, j;" within a "#ifdef..."
> >> Perhaps this points to a bug in coccinelle,
> >> Would you please check ?
> >
> > Thanks for the report. It looks like a bug. But everything is fine if
> > you removed the --defined BOO.
> >
> > julia
>
> Yes, in this example it works without this --defined announcement.
>
> I stumbled on this with something more complex, which for some
> reason I don't understand yet ignores a wanted transformation
> in a #ifdef..#endif, except if I add such a --defined.
> Only then it honours my transformation, but fails with this bug.
I don't think the --defined option has been tested much. Perhaps without
the --defined there is a parse error on the function.
julia
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cocci] perhaps a bug
2018-04-29 13:16 ` Julia Lawall
@ 2018-04-29 13:43 ` Robert Larice
2018-04-29 14:00 ` Julia Lawall
2018-04-29 18:03 ` Julia Lawall
0 siblings, 2 replies; 8+ messages in thread
From: Robert Larice @ 2018-04-29 13:43 UTC (permalink / raw)
To: cocci
Julia Lawall <julia.lawall@lip6.fr> writes:
> On Sun, 29 Apr 2018, Robert Larice wrote:
>
>> Julia Lawall <julia.lawall@lip6.fr> writes:
>>
>> > On Sun, 29 Apr 2018, Robert Larice wrote:
>> >
>> >> Hello,
>> >>
>> >> attached is a small example which does something strange
>> >> to a "int i, j;" within a "#ifdef..."
>> >> Perhaps this points to a bug in coccinelle,
>> >> Would you please check ?
>> >
>> > Thanks for the report. It looks like a bug. But everything is fine if
>> > you removed the --defined BOO.
>> >
>> > julia
>>
>> Yes, in this example it works without this --defined announcement.
>>
>> I stumbled on this with something more complex, which for some
>> reason I don't understand yet ignores a wanted transformation
>> in a #ifdef..#endif, except if I add such a --defined.
>> Only then it honours my transformation, but fails with this bug.
>
> I don't think the --defined option has been tested much. Perhaps without
> the --defined there is a parse error on the function.
>
> julia
Hello Julia,
I've attached a ripped down example to show the behaviour
with regard to the #ifdef
Without the --defined, nothing gets tranformed.
I don't see a parsing problem so far.
Perhaps you can have a look and get an idea why
here the --defined is important.
I've seen other transformations where this was not necessairy.
Best Regards,
Robert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex3.c
Type: text/x-csrc
Size: 372 bytes
Desc: not available
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20180429/ac526743/attachment-0001.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ex3.cocci
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20180429/ac526743/attachment-0001.ksh>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cocci] perhaps a bug
2018-04-29 13:43 ` Robert Larice
@ 2018-04-29 14:00 ` Julia Lawall
2018-04-29 18:03 ` Julia Lawall
1 sibling, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2018-04-29 14:00 UTC (permalink / raw)
To: cocci
On Sun, 29 Apr 2018, Robert Larice wrote:
> Julia Lawall <julia.lawall@lip6.fr> writes:
>
> > On Sun, 29 Apr 2018, Robert Larice wrote:
> >
> >> Julia Lawall <julia.lawall@lip6.fr> writes:
> >>
> >> > On Sun, 29 Apr 2018, Robert Larice wrote:
> >> >
> >> >> Hello,
> >> >>
> >> >> attached is a small example which does something strange
> >> >> to a "int i, j;" within a "#ifdef..."
> >> >> Perhaps this points to a bug in coccinelle,
> >> >> Would you please check ?
> >> >
> >> > Thanks for the report. It looks like a bug. But everything is fine if
> >> > you removed the --defined BOO.
> >> >
> >> > julia
> >>
> >> Yes, in this example it works without this --defined announcement.
> >>
> >> I stumbled on this with something more complex, which for some
> >> reason I don't understand yet ignores a wanted transformation
> >> in a #ifdef..#endif, except if I add such a --defined.
> >> Only then it honours my transformation, but fails with this bug.
> >
> > I don't think the --defined option has been tested much. Perhaps without
> > the --defined there is a parse error on the function.
> >
> > julia
>
> Hello Julia,
>
> I've attached a ripped down example to show the behaviour
> with regard to the #ifdef
> Without the --defined, nothing gets tranformed.
> I don't see a parsing problem so far.
> Perhaps you can have a look and get an idea why
> here the --defined is important.
> I've seen other transformations where this was not necessairy.
Thanks. Coccinelle doesn't show parsing problems by default. You can see
them with spatch --parse-c foo.c or with the --verbose-parsing option.
julia
>
> Best Regards,
> Robert
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cocci] perhaps a bug
2018-04-29 13:43 ` Robert Larice
2018-04-29 14:00 ` Julia Lawall
@ 2018-04-29 18:03 ` Julia Lawall
2018-04-29 18:12 ` Robert Larice
1 sibling, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2018-04-29 18:03 UTC (permalink / raw)
To: cocci
On Sun, 29 Apr 2018, Robert Larice wrote:
> Julia Lawall <julia.lawall@lip6.fr> writes:
>
> > On Sun, 29 Apr 2018, Robert Larice wrote:
> >
> >> Julia Lawall <julia.lawall@lip6.fr> writes:
> >>
> >> > On Sun, 29 Apr 2018, Robert Larice wrote:
> >> >
> >> >> Hello,
> >> >>
> >> >> attached is a small example which does something strange
> >> >> to a "int i, j;" within a "#ifdef..."
> >> >> Perhaps this points to a bug in coccinelle,
> >> >> Would you please check ?
> >> >
> >> > Thanks for the report. It looks like a bug. But everything is fine if
> >> > you removed the --defined BOO.
> >> >
> >> > julia
> >>
> >> Yes, in this example it works without this --defined announcement.
> >>
> >> I stumbled on this with something more complex, which for some
> >> reason I don't understand yet ignores a wanted transformation
> >> in a #ifdef..#endif, except if I add such a --defined.
> >> Only then it honours my transformation, but fails with this bug.
> >
> > I don't think the --defined option has been tested much. Perhaps without
> > the --defined there is a parse error on the function.
> >
> > julia
>
> Hello Julia,
>
> I've attached a ripped down example to show the behaviour
> with regard to the #ifdef
> Without the --defined, nothing gets tranformed.
> I don't see a parsing problem so far.
> Perhaps you can have a look and get an idea why
> here the --defined is important.
> I've seen other transformations where this was not necessairy.
OK, thanks for the example. It is indeed not a parsing problem. When
#ifdefs are reasonably well behaved, Coccinelle internally considers them
to have a control-flow structure like an if - the code in the #ifdef might
be there or it might not. On the other hand your rule requires that there
is exactly one i = 0 on each control-flow path through the loop. If you
just want to remove any that happen to exist, you can instead write:
<...
- i = 0;
...>
This will also remove cases where there are multiple initializations of i
to 0 within the loop.
julia
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cocci] perhaps a bug
2018-04-29 18:03 ` Julia Lawall
@ 2018-04-29 18:12 ` Robert Larice
0 siblings, 0 replies; 8+ messages in thread
From: Robert Larice @ 2018-04-29 18:12 UTC (permalink / raw)
To: cocci
Julia Lawall <julia.lawall@lip6.fr> writes:
> On Sun, 29 Apr 2018, Robert Larice wrote:
>
>> Julia Lawall <julia.lawall@lip6.fr> writes:
>>
>> > On Sun, 29 Apr 2018, Robert Larice wrote:
>> >
>> >> Julia Lawall <julia.lawall@lip6.fr> writes:
>> >>
>> >> > On Sun, 29 Apr 2018, Robert Larice wrote:
>> >> >
>> >> >> Hello,
>> >> >>
>> >> >> attached is a small example which does something strange
>> >> >> to a "int i, j;" within a "#ifdef..."
>> >> >> Perhaps this points to a bug in coccinelle,
>> >> >> Would you please check ?
>> >> >
>> >> > Thanks for the report. It looks like a bug. But everything is fine if
>> >> > you removed the --defined BOO.
>> >> >
>> >> > julia
>> >>
>> >> Yes, in this example it works without this --defined announcement.
>> >>
>> >> I stumbled on this with something more complex, which for some
>> >> reason I don't understand yet ignores a wanted transformation
>> >> in a #ifdef..#endif, except if I add such a --defined.
>> >> Only then it honours my transformation, but fails with this bug.
>> >
>> > I don't think the --defined option has been tested much. Perhaps without
>> > the --defined there is a parse error on the function.
>> >
>> > julia
>>
>> Hello Julia,
>>
>> I've attached a ripped down example to show the behaviour
>> with regard to the #ifdef
>> Without the --defined, nothing gets tranformed.
>> I don't see a parsing problem so far.
>> Perhaps you can have a look and get an idea why
>> here the --defined is important.
>> I've seen other transformations where this was not necessairy.
>
> OK, thanks for the example. It is indeed not a parsing problem. When
> #ifdefs are reasonably well behaved, Coccinelle internally considers them
> to have a control-flow structure like an if - the code in the #ifdef might
> be there or it might not. On the other hand your rule requires that there
> is exactly one i = 0 on each control-flow path through the loop. If you
> just want to remove any that happen to exist, you can instead write:
>
> <...
> - i = 0;
> ...>
>
> This will also remove cases where there are multiple initializations of i
> to 0 within the loop.
>
> julia
Thank You for your helpfull description,
in face of this I can well understand the why,
and how to work around.
Best Regards,
Robert
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-04-29 18:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-29 12:46 [Cocci] perhaps a bug Robert Larice
2018-04-29 12:58 ` Julia Lawall
2018-04-29 13:06 ` Robert Larice
2018-04-29 13:16 ` Julia Lawall
2018-04-29 13:43 ` Robert Larice
2018-04-29 14:00 ` Julia Lawall
2018-04-29 18:03 ` Julia Lawall
2018-04-29 18:12 ` Robert Larice
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.