Hi.

I've just been playing around a bit with Inline::CPR
(Inline::CPR v0.12, Inline v0.52, Perl 5.6.0)
and saw what looks like a bug: the returned value
from perl doesn't do the right thing if it isn't
already a string.  

Here's the code.  

-- cut here -------------  cpr_demo
#!/usr/bin/cpr

/****
 * The perl number is only available to the C
 * program if I force it to have a string representation
 * before I exit perl.  
 *
 ******/

int main(void) {
  char* aNumber;

  /**** The following line fails with a core dump. */
  /* aNumber = CPR_eval(" $a = 12.2 ");   */

  /* But this one works, setting aNumber="12.2". */
  aNumber = CPR_eval(" $a = 12.2 . '' ");

  printf(" Here's a number: ");
  printf( aNumber );
  printf( "\n" );
  return 0;
}
--- cut here ------------------

With the second, awkward form, forcing the 
scalar into a string form, 
i.e. " 12.2 . ''", everything works fine:

 shell> ./cpr_demo
 shell>  Here's a number: 12.2

But with the commented, first CPR_eval, it gives

 shell> ./cpr_demo
 shell> Segmentation fault (core dumped)

The even simpler form 

    aNumber = CPR_eval(" 12.2 ");

runs without crashing, but does not set the C variable.

Regards,

 Jim Mahoney
 [EMAIL PROTECTED]

Reply via email to