Skip to content
Snippets Groups Projects
Unverified Commit 0ef4f35d authored by Guilherme Amadio's avatar Guilherme Amadio
Browse files

Avoid compiler warning in rootcling and rootcling_stage1

Warning:
root/core/rootcling_stage1/src/rootcling_stage1.cxx(38):
	warning #69: integer conversion resulted in truncation

   auto dummyVal = (int)(long)&usedToIdentifyRootClingByDlSym;
                    ^^^

The method above uses a cast to long, followed by a cast to int,
which results in a truncation. That is harmless, since the value
is never used, but generates a compiler warning with ICC 17. This
commit avoids the warning by storing the address of the same symbol
in a static variable instead.
parent 96bdfc2b
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,8 @@ extern "C" {
R__DLLEXPORT void usedToIdentifyRootClingByDlSym() {}
}
// force compiler to emit symbol for function above
static void (*dlsymaddr)() = &usedToIdentifyRootClingByDlSym;
ROOT::Internal::RootCling::TROOTSYSSetter gROOTSYSSetter;
......@@ -32,12 +34,7 @@ static const char *GetEtcDir() {
int main(int argc, char **argv)
{
// Force the emission of the symbol - the compiler cannot know that argv
// is always set.
if (!argv) {
auto dummyVal = (int)(long)&usedToIdentifyRootClingByDlSym;
return dummyVal;
}
(void) dlsymaddr; // avoid unused variable warning
ROOT::Internal::RootCling::DriverConfig config{};
......
......@@ -19,14 +19,12 @@ extern "C" {
R__DLLEXPORT void usedToIdentifyRootClingByDlSym() {}
}
// force compiler to emit symbol for function above
static void (*dlsymaddr)() = &usedToIdentifyRootClingByDlSym;
int main(int argc, char **argv)
{
// Force the emission of the symbol - the compiler cannot know that argv
// is always set.
if (!argv) {
auto dummyVal = (int)(long)&usedToIdentifyRootClingByDlSym;
return dummyVal;
}
(void) dlsymaddr; // avoid unused variable warning
ROOT::Internal::RootCling::DriverConfig config{};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment