PARI/GP Bug report logs - #2227
gp2c fails to create local variables

Package: gp2c; Maintainer for gp2c is Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>; Source for gp2c is src:gp2c.

Reported by: "Perez Bustamante, Adrian" <adrian.pb@gatech.edu>

Date: Sat, 2 May 2020 01:48:01 UTC

Severity: normal

Merged with 2226

Full log


🔗 View this message in rfc822 format

X-Loop: allomber@math.u-bordeaux.fr
Subject: Bug#2227: gp2c fails to create local variables
Reply-To: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>, 2227@pari.math.u-bordeaux.fr
Resent-From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
Resent-To: bug-submit-list@pari.math.u-bordeaux.fr
X-Loop: allomber@math.u-bordeaux.fr
Resent-Date: Sat, 02 May 2020 09:33:01 +0000
Resent-Message-ID: <handler.2227.B2227.158841138012102@pari.math.u-bordeaux.fr>
Resent-Sender: allomber@math.u-bordeaux.fr
X-PARI/GP-PR-Message: followup 2227
X-PARI/GP-PR-Package: gp2c
X-PARI/GP-PR-Keywords: 
References: <BN7PR07MB4851C32604EA9321A79DCBAB91AB0@BN7PR07MB4851.namprd07.prod.outlook.com> <BN7PR07MB4851C32604EA9321A79DCBAB91AB0@BN7PR07MB4851.namprd07.prod.outlook.com>
Received: via spool by 2227-submit@pari.math.u-bordeaux.fr id=B2227.158841138012102
          (code B ref 2227); Sat, 02 May 2020 09:33:01 +0000
Received: (at 2227) by pari.math.u-bordeaux.fr; 2 May 2020 09:23:00 +0000
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
	pari.math.u-bordeaux.fr
X-Spam-Level: 
X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,
	SPF_NEUTRAL autolearn=no autolearn_force=no version=3.4.2
Received: from smtp5-g21.free.fr ([212.27.42.5])
	by pari.math.u-bordeaux.fr with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <Bill.Allombert@math.u-bordeaux.fr>)
	id 1jUoMO-000398-Ht; Sat, 02 May 2020 11:23:00 +0200
Received: from yellowpig (unknown [IPv6:2a01:e35:2f45:9a0:ba76:3fff:fef7:e4d5])
	by smtp5-g21.free.fr (Postfix) with ESMTPS id 36D685FFD1;
	Sat,  2 May 2020 11:22:55 +0200 (CEST)
Received: from bill by yellowpig with local (Exim 4.92)
	(envelope-from <Bill.Allombert@math.u-bordeaux.fr>)
	id 1jUoMJ-0001G4-21; Sat, 02 May 2020 11:22:55 +0200
Date: Sat, 2 May 2020 11:22:55 +0200
From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
To: "Perez Bustamante, Adrian" <adrian.pb@gatech.edu>,
	2227@pari.math.u-bordeaux.fr
Cc: control@pari.math.u-bordeaux.fr
Message-ID: <20200502092255.GB4112@yellowpig>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <BN7PR07MB4851C32604EA9321A79DCBAB91AB0@BN7PR07MB4851.namprd07.prod.outlook.com>
User-Agent: Mutt/1.10.1 (2018-07-13)
merge 2227 2226
thanks
On Sat, May 02, 2020 at 01:35:08AM +0000, Perez Bustamante, Adrian wrote:
> Package: gp2c
> 
> Dear Pari/GP team.
> 
> Thank you very much about the excellent and generous
> work you do for all the scientific community.
> 
> This concerns gp2c
> 
> The specification of the vector() command indicates
> that you can put an command with local variables and
> that this does not affect the index.
> 
> This seems to work in GP as explained. On the other hand,
> the code produced by gp2c fails to create local variables.

Dear Adrian,

I agree with your bug report and diagnostic.
Indeed GP2C does not handle this construction.
However GP2C does create a local variable, as you can see in the 
C code.

  {
->  long i;
    p3 = cgetg(6, t_VEC);
    for (i = 1; i <= 5; ++i)
    {
      i = 2*i; /* Here is the problem !!! */
      gel(p3, i) = gcopy(gel(a, i));
    }
  }
However you are changing its value. So GP2C would need to add
an extra local variable:

  {
    long l1;
    p3 = cgetg(6, t_VEC);
    for (l1 = 1; l1 <= 5; ++l1)
    {
      long i = l1;
      i = 2*i; /* OK now */
      gel(p3, i) = gcopy(gel(a, i));
    }
  }

This is possible, but this leads to less readable C code.

Cheers,
Bill.

Send a report that this bug log contains spam.


Bill Allombert <allomber@math.u-bordeaux.fr>. Last modified: Sat Aug 26 16:37:10 2023; Machine Name: pari

PARI/GP Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.