Project

General

Profile

Bug #25149

Implicit conversion loses integer precision in lardataalg/DetectorInfo/DetectorClocksData.h

Added by Iker de Icaza Astiz 27 days ago. Updated 15 days ago.

Status:
Assigned
Priority:
Low
Category:
-
Target version:
-
Start date:
10/29/2020
Due date:
% Done:

0%

Estimated time:
Occurs In:
Experiment:
-
Co-Assignees:
Duration:

Description

This is a rather nit picky issue, and I don't know wether it actually causes any problems or not. However I've experienced problems with type conversion in other places, so I've started to use compilation flags that throw errors when type conversion occurs.

Namely, I'm using this on one of my CMakeLists.txt:

cet_set_compiler_flags(DIAGS CAUTIOUS
  WERROR
  NO_UNDEFINED
  EXTRA_FLAGS  -Wconversion -Wno-sign-conversion
  )

With that in place I'm getting errors that look like this:

In file included from /sbnd/app/users/icaza/work/sbndcode/srcs/lardataalg/lardataalg/DetectorInfo/DetectorClocks.h:12:
/sbnd/app/users/icaza/work/sbndcode/srcs/lardataalg/lardataalg/DetectorInfo/DetectorClocksData.h:452:69: error:
      implicit conversion loses integer precision: 'const size_t' (aka 'const unsigned long') to 'int'
      [-Werror,-Wshorten-64-to-32]
      return fOpticalClock.TickPeriod() * tick + fOpticalClock.Time(sample, frame) - TriggerTime();
                                                               ~~~~ ^~~~~~

The function Time() is defined in lardataalg/DetectorInfo/ElecClock.h

Don't know how large sample or frame can get, but this might be a silent issue somewhere.

History

#1 Updated by Kyle Knoepfel 23 days ago

  • Status changed from New to Feedback

Iker, if you are aware of other places where implicit narrowing conversions are taking place, please let us know. Would you like to create a PR that addresses this?

#2 Updated by Iker de Icaza Astiz 15 days ago

Hi Kyle. Sure I can do the PR, but it will take me a couple of weeks to have time to come back to this. Feel free to assign the issue to me.

#3 Updated by Kyle Knoepfel 15 days ago

  • Assignee set to Iker de Icaza Astiz
  • Status changed from Feedback to Assigned

Also available in: Atom PDF