[PATCH] Ensure correct order of evaluation in macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Ensure correct order of evaluation in macro

Sahil Kang
Hello,

I'd like to contribute this small patch (attached) that I think will
help prevent some future bugs from occurring in paste.c.
By wrapping the macro's arguments in parentheses, we can ensure that the
correct order of evaluation will take place during preprocessing.

To illustrate, we can use the == operator which has lower evaluation
precedence than the < operator:
     * With the current macro, imax2(3==4, 1) expands to 0.
     * After applying this patch, imax2(3==4, 1) expands to 1 as expected.

Since I'm still relatively new to the mailing list, I've kept this patch
small.
I did notice other macros that have this same issue, so I can start
sending additional patches if this seems okay.

Thanks,
Sahil

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

patch.diff (376 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Ensure correct order of evaluation in macro

Sahil Kang
Hi Duncan,

Would you merge this patch?
I'm planning on sending larger patches in the next few days that fix other macros I've seen, but I figured​ it'd be best to start with a smaller patch.

Thanks,
Sahil

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Ensure correct order of evaluation in macro

Duncan Murdoch-2
On 23/05/2017 11:47 AM, Sahil Kang wrote:
> Hi Duncan,
>
> Would you merge this patch?
> I'm planning on sending larger patches in the next few days that fix other macros I've seen, but I figured​ it'd be best to start with a smaller patch.

No, I generally try to leave the macro stuff to others.

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Ensure correct order of evaluation in macro

Sahil Kang
Hi Martin,

Would you feel comfortable merging my small patch in?
I'd like to send additional patches that will improve these types of
function macros so I'm hoping to start with this small change.

Thanks,
Sahil

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel