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

[perl #133128] yyparse do not preserve ReadOnly flag for negativenumbers pass as reference

Thread Previous
From:
Nicolas R .
Date:
April 20, 2018 11:04
Subject:
[perl #133128] yyparse do not preserve ReadOnly flag for negativenumbers pass as reference
Message ID:
rt-4.0.24-25702-1524222235-1957.133128-75-0@perl.org
# New Ticket Created by  Nicolas R. 
# Please include the string:  [perl #133128]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133128 >


Discovered this difference in behavior while working with Garu on Data::Printer 

A reference to a positive number has the ReadOnly flag set, whereas if that number is negative it's lost during the parsing process.
Note that "~1, -1, - -1, ... all behave in the same where RO is lost"
"+1, 1" on the other side are treated differently by yyparse 

# perl -MDevel::Peek -e 'Dump( \+1 )'
SV = IV(0x7f9f8a815310) at 0x7f9f8a815320
  REFCNT = 1
  FLAGS = (PADTMP,ROK,READONLY,PROTECT)
  RV = 0x7f9f8a8153e0
  SV = IV(0x7f9f8a8153d0) at 0x7f9f8a8153e0
    REFCNT = 1
    FLAGS = (IOK,READONLY,PROTECT,pIOK)
    IV = 1

perl -MDevel::Peek -e 'Dump( \-1 )'
SV = IV(0x7f9d2e003480) at 0x7f9d2e003490
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0x7f9d2e003280
  SV = IV(0x7f9d2e003270) at 0x7f9d2e003280
    REFCNT = 1
    FLAGS = (IOK,pIOK)
    IV = -1

This is probably not a big deal but this difference would, for example, make that simple code attached to the ticket behaves differently.

I've tracked the difference in a gdb session and notice that yyparse was returning earlier for the positive number

 331             if (yyn == YYPACT_NINF)
 332                 goto yydefault;




Thread Previous


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