This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RT #74436: [PATCH] Add -Wwrite-strings
authorRobin Barker <r.m.barker@btinternet.com>
Sat, 14 Aug 2010 18:58:51 +0000 (13:58 -0500)
committerSteve Peters <steve@fisharerojo.org>
Sat, 14 Aug 2010 18:58:51 +0000 (13:58 -0500)
The perl source has for some while been clean to -Wwrite-strings.
I suggest this warning be added to cflags.
The patch makes the appropriate change to cflags.SH and silences a warning from mg.c

cflags.SH
mg.c

index a5d71b9..f57cf2f 100644 (file)
--- a/cflags.SH
+++ b/cflags.SH
@@ -134,7 +134,8 @@ case "$gccversion" in
 '') ;;
 [12]*) ;; # gcc versions 1 (gasp!) and 2 are not good for this.
 Intel*) ;; # # Is that you, Intel C++?
-*)  for opt in -ansi -std=c89 -W -Wextra -Wdeclaration-after-statement -Wendif-labels -Wc++-compat
+*)  for opt in -ansi -std=c89 -W -Wextra -Wdeclaration-after-statement \
+               -Wendif-labels -Wc++-compat -Wwrite-strings
     do
        case " $ccflags " in
        *" $opt "*) ;; # Skip if already there.
diff --git a/mg.c b/mg.c
index 95abbf6..797b57e 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -762,7 +762,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
 {
     dVAR;
     register I32 paren;
-    register char *s = NULL;
+    register const char *s = NULL;
     register REGEXP *rx;
     const char * const remaining = mg->mg_ptr + 1;
     const char nextchar = *remaining;