Skip Menu |

This queue is for tickets about the Math-Complex CPAN distribution.

Report information
The Basics
Id: 39045
Status: resolved
Priority: 0/
Queue: Math-Complex

People
Owner: Nobody in particular
Requestors: cpan [...] millsb.net
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 1.54
Fixed in: (no value)



Subject: great_circle_direction gives wrong answer if 5th argument is supplied
Distribution: Math-Complex-1.54 Module: Math-Trig 1.18 Perl Version: 5.8.8 Operation System: Linux 2.6.20-16-server (Ubuntu 7.04) Math::Trig::great_circle_direction will give a wrong answer if the caller accidentally supplies a non-null value as a 5th argument to the subroutine call. Example: ########################################################### !/usr/bin/perl use strict; use Math::Trig qw(great_circle_direction pi); print great_circle_direction(0, pi/2, 0, pi/4) . "\n"; print great_circle_direction(0, pi/2, 0, pi/4, 2) . "\n"; ########################################################### Results: 0 - correct 0.785398163397448 - incorrect This can be the cause of obscure bugs in the caller's code - particularly because when the value of the 5th argument is close to 1, the error in the value returned is correspondingly small. The bug occurs because on line 169 the 5th argument is accidentally forwarded to &great_circle_distance: 166: sub great_circle_direction { 167: my ( $theta0, $phi0, $theta1, $phi1 ) = @_; 168: 169: my $distance = &great_circle_distance; This could be fixed by passing an explicit argument list to &great_circle_distance: 169: my $distance = great_circle_distance( $theta0, $phi0, $theta1, $phi1 ); or 169: my $distance = great_circle_distance(@_[0..3]);
Fixed in 1.55.