develooper Front page | perl.perl5.porters | Postings from October 2018

[perl #133575] op.c: 'clobbered' warning becomes un-silenced withg++-8

Thread Next
From:
James E Keenan
Date:
October 10, 2018 19:13
Subject:
[perl #133575] op.c: 'clobbered' warning becomes un-silenced withg++-8
Message ID:
rt-4.0.24-14777-1539198770-135.133575-75-0@perl.org
# New Ticket Created by  James E Keenan 
# Please include the string:  [perl #133575]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133575 >


In Oct 2016 a commit made a one-line modification to op.c so as to 
silence one compile-time warning:

#####
$ git show --format=fuller 9af62dcbf8d | cat
commit 9af62dcbf8dcfc51b4a96307e945369b28e0c215
Author:     Lukas Mai <l.mai@web.de>
AuthorDate: Sat Oct 22 17:48:03 2016 +0200
Commit:     Lukas Mai <l.mai@web.de>
CommitDate: Sat Oct 22 17:48:03 2016 +0200

     op.c: silence compiler warning in fold_constants()

     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.

diff --git a/op.c b/op.c
index ebbbf81a5a..cf1399ebbe 100644
--- 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;
#####

Unfortunately, if you compile with g++8, this warning reappears.  From a 
build at 51684e3cb0ae89f477fc488d9d7abc7f0ddbdfa2 with '-Dcc=g++-8' on 
Linux:

#####
$ grep -B3 -A2 -E '^op\.c' make.g++-8.output.txt
echo @`sh  cflags "optimize='-O2'" opmini.o`  -DPERL_IS_MINIPERL 
-DPERL_EXTERNAL_GLOB opmini.c
@g++-8 -c -DPERL_CORE -fwrapv -fno-strict-aliasing -pipe 
-fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64 -ansi -O2 -Wall 
-Werror=declaration-after-statement -Werror=pointer-arith -Wextra 
-Wwrite-strings -DPERL_IS_MINIPERL -DPERL_EXTERNAL_GLOB opmini.c
op.c: In function ‘OP* S_fold_constants(OP*)’:
op.c:5468:34: warning: argument ‘o’ might be clobbered by ‘longjmp’ or 
‘vfork’ [-Wclobbered]
  S_fold_constants(pTHX_ OP *const o)
                         ~~~~~~~~~~^
--
cp DynaLoader.o ../../DynaLoader.o
make[1]: Leaving directory '/home/jkeenan/gitwork/perl/ext/DynaLoader'
g++-8 -c -DPERL_CORE -fwrapv -fno-strict-aliasing -pipe 
-fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64 -ansi -O2 -Wall 
-Werror=declaration-after-statement -Werror=pointer-arith -Wextra 
-Wwrite-strings op.c
op.c: In function ‘OP* S_fold_constants(OP*)’:
op.c:5468:34: warning: argument ‘o’ might be clobbered by ‘longjmp’ or 
‘vfork’ [-Wclobbered]
  S_fold_constants(pTHX_ OP *const o)
                         ~~~~~~~~~~^
#####

Can this be alleviated?

Thank you very much.
Jim Keenan

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About