Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.91k stars 542 forks source link

\x{} returns 0 without a warning #10175

Closed p5pRT closed 13 years ago

p5pRT commented 14 years ago

Migrated from rt.perl.org#72798 (status was 'resolved')

Searchable as RT72798$

p5pRT commented 14 years ago

From @khwilliamson

This is a bug report for perl from khw@​khw-desktop.nonet\, generated with the help of perlbug 1.39 running under perl 5.11.4.


./perl -w -Ilib -E 'say "\x{}" eq "\0"' 1

I think \x{} should really be a syntax error. It should at least give a warning. I propose having it give a deprecated warning while continuing to return 0.



Flags​:   category=core   severity=low


Site configuration information for perl 5.11.4​:

Configured by khw at Sat Jan 23 13​:32​:28 MST 2010.

Summary of my perl5 (revision 5 version 11 subversion 4) configuration​:   Commit id​: d0a76353c03de55a7ec9f5f128afee8d3c83e23f   Platform​:   osname=linux\, osvers=2.6.27-16-generic\, archname=i686-linux   uname='linux khw-desktop 2.6.27-16-generic #1 smp tue dec 1 17​:56​:54 utc 2009 i686 gnulinux '   config_args='-s -d -Dprefix=/home/khw/blead -Dusedevel -D'optimize=-g3' -A'optimize=-g3' -A'optimize=-O0''   hint=recommended\, useposix=true\, d_sigaction=define   useithreads=undef\, usemultiplicity=undef   useperlio=define\, d_sfio=undef\, uselargefiles=define\, usesocks=undef   use64bitint=undef\, use64bitall=undef\, uselongdouble=undef   usemymalloc=n\, bincompat5005=undef   Compiler​:   cc='cc'\, ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'\,   optimize='-O0 -g3'\,   cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'   ccversion=''\, gccversion='4.3.2'\, gccosandvers=''   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=12   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8   alignbytes=4\, prototype=define   Linker and Libraries​:   ld='cc'\, ldflags =' -fstack-protector -L/usr/local/lib'   libpth=/usr/local/lib /lib /usr/lib   libs=-lnsl -ldl -lm -lcrypt -lutil -lc   perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc   libc=/lib/libc-2.8.90.so\, so=so\, useshrplib=false\, libperl=libperl.a   gnulibc_version='2.8.90'   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags='-Wl\,-E'   cccdlflags='-fPIC'\, lddlflags='-shared -g3 -g3 -O0 -L/usr/local/lib -fstack-protector'

Locally applied patches​:


@​INC for perl 5.11.4​:   /home/khw/blead/lib/perl5/site_perl/5.11.4/i686-linux   /home/khw/blead/lib/perl5/site_perl/5.11.4   /home/khw/blead/lib/perl5/5.11.4/i686-linux   /home/khw/blead/lib/perl5/5.11.4   /home/khw/blead/lib/perl5/site_perl   .


Environment for perl 5.11.4​:   HOME=/home/khw   LANG=en_US.UTF-8   LANGUAGE (unset)   LD_LIBRARY_PATH (unset)   LOGDIR (unset)

PATH=/home/khw/bin​:/home/khw/print/bin​:/bin​:/usr/local/sbin​:/usr/local/bin​:/usr/sbin​:/usr/bin​:/sbin​:/usr/games​:/opt/real/RealPlayer​:/home/khw/cxoffice/bin   PERL_BADLANG (unset)   SHELL=/bin/ksh

p5pRT commented 14 years ago

From @abigail

On Sat\, Feb 13\, 2010 at 09​:17​:47PM -0800\, karl williamson wrote​:

# New Ticket Created by karl williamson # Please include the string​: [perl #72798] # in the subject line of all future correspondence about this issue. # \<URL​: http​://rt.perl.org/rt3/Ticket/Display.html?id=72798 >

This is a bug report for perl from khw@​khw-desktop.nonet\, generated with the help of perlbug 1.39 running under perl 5.11.4.

----------------------------------------------------------------- ./perl -w -Ilib -E 'say "\x{}" eq "\0"' 1

I think \x{} should really be a syntax error. It should at least give a warning. I propose having it give a deprecated warning while continuing to return 0. -----------------------------------------------------------------

Why? \x{} being a syntax error isn't particular useful for the programmer. Having \x{} returning \0 is probably the best thing it can do. Now\, if \x{} was new\, forbidden \x{} might be a good idea; but \x{} has been around for a while\, and while I suspect an empty \x{} isn't used a lot\, turning it into a syntax error just for the sake of turning it into a syntax error makes me itchy.

Abigail

p5pRT commented 14 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 14 years ago

From @druud62

Abigail wrote​:

On Sat\, Feb 13\, 2010 at 09​:17​:47PM -0800\, karl williamson wrote​:

# New Ticket Created by karl williamson # Please include the string​: [perl #72798] # in the subject line of all future correspondence about this issue. # \<URL​: http​://rt.perl.org/rt3/Ticket/Display.html?id=72798 >

This is a bug report for perl from khw@​khw-desktop.nonet\, generated with the help of perlbug 1.39 running under perl 5.11.4.

----------------------------------------------------------------- ./perl -w -Ilib -E 'say "\x{}" eq "\0"' 1

I think \x{} should really be a syntax error. It should at least give a warning. I propose having it give a deprecated warning while continuing to return 0. -----------------------------------------------------------------

Why? \x{} being a syntax error isn't particular useful for the programmer. Having \x{} returning \0 is probably the best thing it can do. Now\, if \x{} was new\, forbidden \x{} might be a good idea; but \x{} has been around for a while\, and while I suspect an empty \x{} isn't used a lot\, turning it into a syntax error just for the sake of turning it into a syntax error makes me itchy.

I like the default. Makes me think of //.

perl -Mstrict -wle'

  my ($empty\, $undef) = (""\, undef);

  $_ = my $text = "a bc def\n";

  m/bc/;   $text =~ s/$empty/xx/;

  m/d/;

  $text =~ s/$undef/???/;

  print "\n"\, $text;

  print ord() for split ""\, "\x{}\x{$empty}\x{$undef}"; ' Illegal hexadecimal digit '$' ignored at -e line 16. Illegal hexadecimal digit '$' ignored at -e line 16. Use of uninitialized value in regexp compilation at -e line 12.

a xx ???ef

0 0 0

-- Ruud

p5pRT commented 13 years ago

From @khwilliamson

I have been persuaded not to pursue this\, as people write code that depends on it being this way --Karl Williamson

p5pRT commented 13 years ago

@khwilliamson - Status changed from 'open' to 'resolved'