Problem 1843 - Failure of G4UnitDefinition::GetValueOf() should be a "hard error", not a warning
Summary: Failure of G4UnitDefinition::GetValueOf() should be a "hard error", not a war...
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: global/management (show other problems)
Version: 10.2
Hardware: All All
: P5 normal
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 2016-03-11 19:36 CET by gahs
Modified: 2016-03-16 21:33 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description gahs 2016-03-11 19:36:45 CET
When G4UnitDefinition::GetValueOf(const G4String& str) is asked for the value of a unit that does not exist, it prints a non-fatal warning and returns 0.  This is pretty much guaranteed to give wrong simulation results, so it really should be a fatal exception, or some other hard, simulation-stopping exception.

The only reason I can think of for not making it fatal is that there is currently no other simple way to query whether a unit exists in the table.  This could be easily remedied.

Note bugs #1535 and #1842 are similar but a little different, since those bug reports both request that a check for invalid units be added. (E.g., "km" for an energy.)  Here the request is for a general hard failure in the case of completely unrecognized units, since multiplying by 0 is never a desirable unit conversion.
Comment 1 Gabriele Cosmo 2016-03-16 21:33:59 CET
I agree with the suggestion. I submitted the change to the current development branch and will be included in the next release. Thanks.