Charles Greathouse on Fri, 15 Jun 2012 16:29:10 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
segfault on reading vector |
I wrote a quick script to help someone with an "insert operators into 123456789 to make 100" problem. In essence, it was 9 nested loops building a string with if(trap(,0,eval(s9)==100), listput(v,s9) ) inside, where v is a List. At the end it returns Vec(v). The program runs without problems, but when I try to access the return value I get *** type: bug in PARI/GP (Segmentation Fault), please report on both GP/PARI CALCULATOR Version 2.6.0 (development git-d1d257d) i686 running mingw (ix86/GMP-5.0.1 kernel) 32-bit version compiled: May 9 2012, gcc version 4.6.3 (GCC) (readline v6.2 enabled, extended help enabled) and even on the old GP/PARI CALCULATOR Version 2.4.2 (development CHANGES-1.1971) i686 running cygwin (ix86/GMP-4.2.1 kernel) 32-bit version compiled: Dec 23 2007, gcc-3.4.4 (cygming special, gdc 0.12, using dmd 0.125) (readline v5.2 enabled, extended help enabled) I don't know why this is -- a general bug, a Windows-specific bug, or a problem with my code. I tried it with iferr as well (only on 2.6.0) with the same result. If I change the program to print the results and return a tally, it works without difficulty. The full code is test()={ my(s1,s2,s3,s4,s5,s6,s7,s8,s9,op=["","+","-","*","/"],v=List()); for(n1=1,5, s1=Str(1, op[n1]); for(n2=1,5, s2=Str(s1, 2, op[n2]); for(n3=1,5, s3=Str(s2, 3, op[n3]); for(n4=1,5, s4=Str(s3, 4, op[n4]); for(n5=1,5, s5=Str(s4, 5, op[n5]); for(n6=1,5, s6=Str(s5, 6, op[n6]); for(n7=1,5, s7=Str(s6, 7, op[n7]); for(n8=1,5, s8=Str(s7, 8, op[n8]); for(n9=1,5, s9=Str(s8, 9, op[n9]); if(trap(,0,eval(s9)==100), listput(v,s9) ) ) ) ) ) ) ) ) ) ); Vec(v) }; (inelegant, but runs fast enough) Charles Greathouse Analyst/Programmer Case Western Reserve University