This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
op.c: silence compiler warning in fold_constants()
authorLukas Mai <l.mai@web.de>
Sat, 22 Oct 2016 15:48:03 +0000 (17:48 +0200)
committerLukas Mai <l.mai@web.de>
Sat, 22 Oct 2016 15:48:03 +0000 (17:48 +0200)
op.c: In function ‘S_fold_constants’:
op.c:4374:28: warning: argument ‘o’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]
 S_fold_constants(pTHX_ OP *o)
                            ^

This warning occurs for non-volatile local variables where the compiler
can't prove that their value doesn't change between setjmp and longjmp
(because the modified value may only be stored in a register which
longjmp overwrites). Adding 'const' apparently convinces the compiler
that no such modification occurs.

op.c

diff --git a/op.c b/op.c
index ebbbf81..cf1399e 100644 (file)
--- a/op.c
+++ b/op.c
@@ -4371,7 +4371,7 @@ S_op_integerize(pTHX_ OP *o)
 }
 
 static OP *
-S_fold_constants(pTHX_ OP *o)
+S_fold_constants(pTHX_ OP *const o)
 {
     dVAR;
     OP * VOL curop;