[ROOT-4592] TLorentzVector constructor Created: 15/Oct/12  Updated: 12/Apr/13  Resolved: 17/Oct/12

Status: Closed
Project: ROOT
Component/s: Math Libraries
Affects Version/s: < v5-28-00
Fix Version/s: None

Type: Bug Priority: High
Reporter: Ruggero Turra Assignee: Lorenzo Moneta
Resolution: Fixed Votes: 0
Labels: None
Environment:

All


External issue ID: bugs98203
External issue URL: https://savannah.cern.ch/bugs/?98203
Development:

 Description   

this is a copy and paste from: http://root.cern.ch/phpBB3/viewtopic.php?f=3&amp;amp;t=15470&amp;amp;sid=7883219728eb49a8fcdbc973430a47e7&amp;amp;p=66500#p66500

refer to it for additional details:

Hello, today I spent a lot of time to find this bug in my program: I have a function

CODE: SELECT ALL
void function(const TLorentzVector v);

but for some reson I was calling it with
CODE: SELECT ALL
function(integer_value);

it was very difficult because the compiler didn't tell me anything. In fact I found that an integer can be converted to a TLorentzVector

CODE: SELECT ALL
TLorentzVector a;
a = 1.2;

is this a feature? Do we need it? I think it is dangerous



 Comments   
Comment by Lorenzo Moneta [ 17/Oct/12 ]

Hi,

The TLorentzVector constructor should have at least an "explicit" keyword.
However I think it is bad in that case having a constructor with

TLorentzVector(Double_t x = 0.0, Double_t y = 0.0,
Double_t z = 0.0, Double_t t = 0.0);

It should not have default arguments.
TLorentzVector v(2,2) it does not make sense
Also
TLorentzVector v(0) it will not compile because it is ambigous with the other constructors.
I will fix it adding in addition a proper default constructor
TLorentzVector()
and
TLorentzVector(Double_t x , Double_t y,
Double_t z , Double_t t);

Thank you for reporting this issue

Lorenzo

Comment by Lorenzo Moneta [ 17/Oct/12 ]

This is fixed now in the svn trunk, revision 46612

http://root.cern.ch/viewvc?view=rev&amp;revision=46612

Lorenzo

Generated at Sun Sep 22 01:26:41 CEST 2019 using Jira 7.13.1#713001-sha1:5e06076c2d215a6f699b7e5c90ab2fae7ba5a1ce.