Skip to content

Commit

Permalink
remove C++20 deprecated volatile argument
Browse files Browse the repository at this point in the history
This produced warnings like:

g++ -c   -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing \
  -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
  -xc++ -I/usr/lib/llvm-18/include -std=c++17 -fno-exceptions \
  -funwind-tables -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS \
  -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS  -fexceptions \
  -I/usr/lib/x86_64-linux-gnu/perl5/5.36/Imager/include -std=c++23 \
  -O2 -g   -DVERSION=\"1.000\" -DXS_VERSION=\"1.000\" -fPIC \
  "-I/usr/lib/x86_64-linux-gnu/perl/5.36/CORE"   LLVM.c
In file included from /usr/lib/x86_64-linux-gnu/perl/5.36/CORE/perl.h:5798,
                 from LLVM.xs:15:
/usr/lib/x86_64-linux-gnu/perl/5.36/CORE/proto.h:392:65: warning: ‘volatile’-qualified parameter is deprecated [-Wvolatile]
  392 | PERL_CALLCONV I32       Perl_call_sv(pTHX_ SV* sv, volatile I32 flags);
      |                                                    ~~~~~~~~~~~~~^~~~~

I haven't been able to produce this when building perl itself as C++
since it requires a modern -std argument to reproduce, and that breaks
the build in other ways.  It is reproducible when building a C++
XS module with gcc and -std=c++20 or later.

In a strict standard sense flags does not need to be volatile since
flags is not modified between setjmp() and longjmp(), but due to a
bug in gcc, gcc complains flags could be clobbered.

GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21161
  • Loading branch information
tonycoz committed Oct 25, 2023
1 parent f8f432a commit 11899b5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ CTadop |Malloc_t|calloc |MEM_SIZE elements \
AOdp |SSize_t|call_pv |NN const char *sub_name \
|I32 flags
AOdp |SSize_t|call_sv |NN SV *sv \
|volatile I32 flags
|I32 flags
: Used in several source files
Rp |bool |cando |Mode_t mode \
|bool effective \
Expand Down
6 changes: 5 additions & 1 deletion perl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3060,7 +3060,7 @@ See L<perlcall>.
*/

SSize_t
Perl_call_sv(pTHX_ SV *sv, volatile I32 flags)
Perl_call_sv(pTHX_ SV *sv, I32 arg_flags)
/* See G_* flags in cop.h */
{
LOGOP myop; /* fake syntax tree node */
Expand All @@ -3070,6 +3070,10 @@ Perl_call_sv(pTHX_ SV *sv, volatile I32 flags)
bool oldcatch = CATCH_GET;
int ret;
OP* const oldop = PL_op;
/* Since we don't modify flags after setjmp() we don't really need to make
flags volatile, but gcc complains that it could be clobbered anyway.
*/
volatile I32 flags = arg_flags;
dJMPENV;

PERL_ARGS_ASSERT_CALL_SV;
Expand Down
2 changes: 1 addition & 1 deletion proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 11899b5

Please sign in to comment.