Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLT GCC 7 Cleanup #17239

Merged
merged 2 commits into from Jan 22, 2017
Merged

HLT GCC 7 Cleanup #17239

merged 2 commits into from Jan 22, 2017

Conversation

davidlt
Copy link
Contributor

@davidlt davidlt commented Jan 20, 2017

Two commits cleaning up GCC 7 compilation errors in HLT packages.

David Abdurachmanov added 2 commits January 20, 2017 22:34
TString in ROOT support std::string_view which was added into C++17
standard and CMSSW since GCC 6 is compiled with C++17. GCC 7 will
provide a ful C++17 language support and most of C++ standard library.

TString defines two conversion operators, one for const char * and one
for std::string_view. The std::string can be constructor by both of them
thus causing compiler to error on it.

Use static_cast to explicitly select conversion operator which would be
compatible with previous C++ standards.

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
According GCC the output string could be up to 315 chars long. Adjust
buffer to accommodate that.

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
@cmsbuild
Copy link
Contributor

A new Pull Request was created by @davidlt for CMSSW_9_0_X.

It involves the following packages:

HLTrigger/HLTanalyzers
HLTrigger/Tools

@perrotta, @cmsbuild, @silviodonato, @Martin-Grunewald, @fwyzard, @davidlange6 can you please review it and eventually sign? Thanks.
@Martin-Grunewald this is something you requested to watch as well.
@davidlange6, @smuzaffar you are the release manager for this.

cms-bot commands are listed here #13028

@davidlt
Copy link
Contributor Author

davidlt commented Jan 20, 2017

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 20, 2017

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/17355/console Started: 2017/01/20 23:05

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Comparison job queued.

@cmsbuild
Copy link
Contributor

@@ -1880,16 +1880,16 @@ int main(int argc, char ** argv) {
}
}

char value[10] ;
char value[330] ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need 330 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the GCC the format can generate a string up to 316 bytes.

error: '%9.4f' directive output may be truncated writing between 9 and 315 bytes into a region of size 10 [-Werror=format-truncation=]
note: format output between 10 and 316 bytes into a destination of size 10

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree... anyway, why is this an error and not a warning ? snprintf should just truncate the output, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an error in GCC 7. It's a new flag. It's triggered for both, overflows and truncations. And yes, snprintf will just print just keep n-1 chars from the format string (1 char is needed for NULL termination). The buffer needs to be big, because we are printing double here. I checked at least DBL_MAX and that seems to be 308+ chars.

Looks like the warning/errors is not triggered if one checks for return value of snprintf. In that case GCC assumes that developer detected truncation and handled it correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The buffer needs to be big, because we are printing double here

True, but we it looks like we are printing bin counts and/or execution times here... if the execution time needs 300 characters to print, it's unlikely I'll stick around to see it printed :-)

@@ -557,7 +557,7 @@ void HLTInfo::analyze(const edm::Handle<edm::TriggerResults> & h
// ...Fill the corresponding accepts in branch-variables
l1flag[iBit] = gtDecisionWord[iBit];

std::string l1triggername= std::string (algoBitToName[iBit]);
std::string l1triggername= std::string (static_cast<const char *>(algoBitToName[iBit]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh... I'm actually sorry for having this kind of code under HLTrigger/, even though it's not used in any production workflow (and possibly not used any more at all, since it doesn't look like it was ever ported to the L! trigger used in Run 2).
OK for the minimal fix, I'll add it to my list of things to be cleaned up (or dropped).

@fwyzard
Copy link
Contributor

fwyzard commented Jan 21, 2017

+1

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next CMSSW_9_0_X IBs (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @davidlange6, @smuzaffar

@davidlange6
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 0a2f88f into cms-sw:CMSSW_9_0_X Jan 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants