Skip to content

Resolve Clang warnings#9542

Merged
hahnjo merged 6 commits intoroot-project:masterfrom
hahnjo:clang-warnings
Feb 14, 2022
Merged

Resolve Clang warnings#9542
hahnjo merged 6 commits intoroot-project:masterfrom
hahnjo:clang-warnings

Conversation

@hahnjo
Copy link
Copy Markdown
Member

@hahnjo hahnjo commented Jan 11, 2022

Building with current Clang main produced a number of warnings.

@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

pcanal added a commit to pcanal/root that referenced this pull request Jan 14, 2022
This fixes issue root-project#9543

In the issue root-project#9543, the unusual situation is the combination of:

* there is (intentionally) no dictionary for `std::map<int,std::vector<int>>`
* consequently we use an "emulated collection proxy" for that collection
* there is (unintentional due to external config) interpreter information/ClassInfo for `std::map<int,std::vector<int>>`

The crux of the issue root-project#9542 is:

* TClass::fSizeof info prefers the information from the CollectionProxy
* TStreamerInfo::fSize is set to the value of TClass::fSizeOf
* TClass:New prefers the constructor from the interpreter
* TStreamerInfo::New was using TClass::New for that case
* On the failing platform, the `sizeof(std::map<int,std::vector<int>>)` is larger than the size of the emulated collection.

Since the I/O and TStreamerInfo uses the TCollection proxy and all of TStreamerInfo needs to prefer the information from the collection proxy (including the 'sizeof').  To fix root-project#9542 the solution is for
* TStremearInfo::New to prefer/use TCollectionProxy::New over TClass::New (i.e. the interpreted constructor in this particular case).
@pcanal pcanal closed this in #9581 Jan 19, 2022
pcanal added a commit that referenced this pull request Jan 19, 2022
This fixes issue #9543

In the issue #9543, the unusual situation is the combination of:

* there is (intentionally) no dictionary for `std::map<int,std::vector<int>>`
* consequently we use an "emulated collection proxy" for that collection
* there is (unintentional due to external config) interpreter information/ClassInfo for `std::map<int,std::vector<int>>`

The crux of the issue #9542 is:

* TClass::fSizeof info prefers the information from the CollectionProxy
* TStreamerInfo::fSize is set to the value of TClass::fSizeOf
* TClass:New prefers the constructor from the interpreter
* TStreamerInfo::New was using TClass::New for that case
* On the failing platform, the `sizeof(std::map<int,std::vector<int>>)` is larger than the size of the emulated collection.

Since the I/O and TStreamerInfo uses the TCollection proxy and all of TStreamerInfo needs to prefer the information from the collection proxy (including the 'sizeof').  To fix #9542 the solution is for
* TStremearInfo::New to prefer/use TCollectionProxy::New over TClass::New (i.e. the interpreted constructor in this particular case).
pcanal added a commit to pcanal/root that referenced this pull request Jan 19, 2022
This fixes issue root-project#9543

In the issue root-project#9543, the unusual situation is the combination of:

* there is (intentionally) no dictionary for `std::map<int,std::vector<int>>`
* consequently we use an "emulated collection proxy" for that collection
* there is (unintentional due to external config) interpreter information/ClassInfo for `std::map<int,std::vector<int>>`

The crux of the issue root-project#9542 is:

* TClass::fSizeof info prefers the information from the CollectionProxy
* TStreamerInfo::fSize is set to the value of TClass::fSizeOf
* TClass:New prefers the constructor from the interpreter
* TStreamerInfo::New was using TClass::New for that case
* On the failing platform, the `sizeof(std::map<int,std::vector<int>>)` is larger than the size of the emulated collection.

Since the I/O and TStreamerInfo uses the TCollection proxy and all of TStreamerInfo needs to prefer the information from the collection proxy (including the 'sizeof').  To fix root-project#9542 the solution is for
* TStremearInfo::New to prefer/use TCollectionProxy::New over TClass::New (i.e. the interpreted constructor in this particular case).
@hahnjo
Copy link
Copy Markdown
Member Author

hahnjo commented Jan 19, 2022

Eh no, @pcanal's PR just contained a typo 😅

ping @Axel-Naumann @pcanal

@hahnjo hahnjo reopened this Jan 19, 2022
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

pcanal added a commit to pcanal/root that referenced this pull request Jan 19, 2022
This fixes issue root-project#9543

In the issue root-project#9543, the unusual situation is the combination of:

* there is (intentionally) no dictionary for `std::map<int,std::vector<int>>`
* consequently we use an "emulated collection proxy" for that collection
* there is (unintentional due to external config) interpreter information/ClassInfo for `std::map<int,std::vector<int>>`

The crux of the issue root-project#9542 is:

* TClass::fSizeof info prefers the information from the CollectionProxy
* TStreamerInfo::fSize is set to the value of TClass::fSizeOf
* TClass:New prefers the constructor from the interpreter
* TStreamerInfo::New was using TClass::New for that case
* On the failing platform, the `sizeof(std::map<int,std::vector<int>>)` is larger than the size of the emulated collection.

Since the I/O and TStreamerInfo uses the TCollection proxy and all of TStreamerInfo needs to prefer the information from the collection proxy (including the 'sizeof').  To fix root-project#9542 the solution is for
* TStremearInfo::New to prefer/use TCollectionProxy::New over TClass::New (i.e. the interpreted constructor in this particular case).
pcanal added a commit that referenced this pull request Jan 19, 2022
This fixes issue #9543

In the issue #9543, the unusual situation is the combination of:

* there is (intentionally) no dictionary for `std::map<int,std::vector<int>>`
* consequently we use an "emulated collection proxy" for that collection
* there is (unintentional due to external config) interpreter information/ClassInfo for `std::map<int,std::vector<int>>`

The crux of the issue #9542 is:

* TClass::fSizeof info prefers the information from the CollectionProxy
* TStreamerInfo::fSize is set to the value of TClass::fSizeOf
* TClass:New prefers the constructor from the interpreter
* TStreamerInfo::New was using TClass::New for that case
* On the failing platform, the `sizeof(std::map<int,std::vector<int>>)` is larger than the size of the emulated collection.

Since the I/O and TStreamerInfo uses the TCollection proxy and all of TStreamerInfo needs to prefer the information from the collection proxy (including the 'sizeof').  To fix #9542 the solution is for
* TStremearInfo::New to prefer/use TCollectionProxy::New over TClass::New (i.e. the interpreted constructor in this particular case).
pcanal added a commit that referenced this pull request Jan 19, 2022
This fixes issue #9543

In the issue #9543, the unusual situation is the combination of:

* there is (intentionally) no dictionary for `std::map<int,std::vector<int>>`
* consequently we use an "emulated collection proxy" for that collection
* there is (unintentional due to external config) interpreter information/ClassInfo for `std::map<int,std::vector<int>>`

The crux of the issue #9542 is:

* TClass::fSizeof info prefers the information from the CollectionProxy
* TStreamerInfo::fSize is set to the value of TClass::fSizeOf
* TClass:New prefers the constructor from the interpreter
* TStreamerInfo::New was using TClass::New for that case
* On the failing platform, the `sizeof(std::map<int,std::vector<int>>)` is larger than the size of the emulated collection.

Since the I/O and TStreamerInfo uses the TCollection proxy and all of TStreamerInfo needs to prefer the information from the collection proxy (including the 'sizeof').  To fix #9542 the solution is for
* TStremearInfo::New to prefer/use TCollectionProxy::New over TClass::New (i.e. the interpreted constructor in this particular case).
@pcanal
Copy link
Copy Markdown
Member

pcanal commented Jan 19, 2022

@hahnjo Sorry about that :(

@phsft-bot
Copy link
Copy Markdown

Build failed on mac1015/python3.
Running on macitois21.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

Copy link
Copy Markdown
Member

@pcanal pcanal left a comment

Choose a reason for hiding this comment

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

For the core/io/tree parts

@hahnjo
Copy link
Copy Markdown
Member Author

hahnjo commented Jan 21, 2022

@phsft-bot build

@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-performance-centos8-multicore/default.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Failing tests:

rahulgrit pushed a commit to rahulgrit/root that referenced this pull request Jan 25, 2022
This fixes issue root-project#9543

In the issue root-project#9543, the unusual situation is the combination of:

* there is (intentionally) no dictionary for `std::map<int,std::vector<int>>`
* consequently we use an "emulated collection proxy" for that collection
* there is (unintentional due to external config) interpreter information/ClassInfo for `std::map<int,std::vector<int>>`

The crux of the issue root-project#9542 is:

* TClass::fSizeof info prefers the information from the CollectionProxy
* TStreamerInfo::fSize is set to the value of TClass::fSizeOf
* TClass:New prefers the constructor from the interpreter
* TStreamerInfo::New was using TClass::New for that case
* On the failing platform, the `sizeof(std::map<int,std::vector<int>>)` is larger than the size of the emulated collection.

Since the I/O and TStreamerInfo uses the TCollection proxy and all of TStreamerInfo needs to prefer the information from the collection proxy (including the 'sizeof').  To fix root-project#9542 the solution is for
* TStremearInfo::New to prefer/use TCollectionProxy::New over TClass::New (i.e. the interpreted constructor in this particular case).
@hahnjo
Copy link
Copy Markdown
Member Author

hahnjo commented Jan 27, 2022

ping @Axel-Naumann

Copy link
Copy Markdown
Member

@Axel-Naumann Axel-Naumann left a comment

Choose a reason for hiding this comment

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

We need some help from @lmoneta and @pcanal here. Other than whhere I commented this looks great. Thank you so much, @hahnjo and clang!

xmin = xmin - range;
range *= 2;
binsize *= 2;
// // make sure that the merging will be correct
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the future reader: this is 007bbba

TBasket* basket = (TBasket*)branch->GetListOfBaskets()->UncheckedAt(j);
if (basket) {
ndrop += basket->DropBuffers();
basket->DropBuffers();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pcanal should DropBuffers() return ndrop?

@hahnjo
Copy link
Copy Markdown
Member Author

hahnjo commented Feb 8, 2022

ping @lmoneta @pcanal

Copy link
Copy Markdown
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

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

Thank you Jonas for fixing these warnings,
I have just a small comment on the changes in tmva/tmva/src/PDEFoam.cxx
Apologies for the delay in doing this, I missed the notification!

Recent Clang complains:
warning: 'sizeof (val)' will return the size of the pointer, not the array itself

This is correct: If T is an array, "const T*" is a pointer to an array
(not a pointer to the first element!). Then sizeof(val) is the size of
a pointer, while sizeof(val[0]) is the size of the array behind it. The
correct expression could have been sizeof(*val) / sizeof((*val)[0]),
but I find it highly unlikely that somebody passes in a pointer to an
array.
    warning: use of bitwise '&' with boolean operands
and
    warning: use of bitwise '|' with boolean operands
Pass it for consistency, even though the implementation will ignore
it.
These were updated / set, but not used. Recent Clang is able to
detect and warn about this pattern.
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@hahnjo
Copy link
Copy Markdown
Member Author

hahnjo commented Feb 14, 2022

Even with this, I'm still seeing quite a number of other warnings with Clang 13. I'm not sure if I missed them before, forgot to rebuild the files that trigger them, or they got introduced while this PR was pending - probably a mixture of all three. I've decided to not add them to this PR and instead merge what I have right now. I'll see if I'm motivated to address the other warnings in future PRs.

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-ubuntu2004/soversion.
Running on root-ubuntu-2004-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@hahnjo hahnjo merged commit c9d376c into root-project:master Feb 14, 2022
@hahnjo hahnjo deleted the clang-warnings branch February 14, 2022 13:52
pcanal added a commit to pcanal/root that referenced this pull request Oct 4, 2022
This fixes issue root-project#9543

In the issue root-project#9543, the unusual situation is the combination of:

* there is (intentionally) no dictionary for `std::map<int,std::vector<int>>`
* consequently we use an "emulated collection proxy" for that collection
* there is (unintentional due to external config) interpreter information/ClassInfo for `std::map<int,std::vector<int>>`

The crux of the issue root-project#9542 is:

* TClass::fSizeof info prefers the information from the CollectionProxy
* TStreamerInfo::fSize is set to the value of TClass::fSizeOf
* TClass:New prefers the constructor from the interpreter
* TStreamerInfo::New was using TClass::New for that case
* On the failing platform, the `sizeof(std::map<int,std::vector<int>>)` is larger than the size of the emulated collection.

Since the I/O and TStreamerInfo uses the TCollection proxy and all of TStreamerInfo needs to prefer the information from the collection proxy (including the 'sizeof').  To fix root-project#9542 the solution is for
* TStremearInfo::New to prefer/use TCollectionProxy::New over TClass::New (i.e. the interpreted constructor in this particular case).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants