- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have been hitting a problem using Inspector under Linux when building the code with GCC (FYI, building with Clang and MSVC does not seem to suffer from the same problem.) I think that this (or something similar) was raised 12+ years ago here: https://community.intel.com/t5/Analyzers/Uninitialized-memory-access-in-struct-member-padding/m-p/788410/highlight/true#M1060 but none of the workarounds mentioned there are possible as the structures that we are using are not under our control (so we can't manually pad) and we are not using malloc or new.
A minimal reproducer is:
#include <iostream>
#include <ostream>
#include <memory>
struct Foo
{
char a, b, c;
// A padding byte will be inserted here to align the following int
int d;
};
int main()
{
auto pFoo = std::make_unique<Foo>();
Foo pOtherFoo;
pOtherFoo = *pFoo;
std::cout << pOtherFoo.d << std::endl;
return 0;
}
Building this with g++ repro.cpp using gcc 10.2.1 (under Debian Bullseye) and then running Inspector on the a.out produced reports "Invalid partial memory access" on the structure assignment.
I think that this is because std::make_unique performs value-initialization, which results in default-initialization on this structure... and default-initialization makes no guarantees about initializing padding.
I've confirmed that by adding a user-defined (no-op) constructor to the structure (so the structure must be zero-initialized instead of default-initialized, which does guarantee that padding is filled with zeros) and Inspector no longer reports the problem.
We could suppress the issue type globally (individual suppressions would be too difficult to maintain) but it has caught the occasional issue in the past, so I would rather find a solution to this issue, if possible.
Thanks in advance for you help,
Steve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Inspector is no longer included in the Intel® HPC Toolkit. It continues to be downloadable as a standalone package and it will be discontinued in 2025 or later. Customers who have purchased Intel® Priority Support will continue to receive support. Please see Intel Inspector deprecation article for more information.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for reporting the issue and providing the reproducer. We will investigate and give an update then.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Inspector is no longer included in the Intel® HPC Toolkit. It continues to be downloadable as a standalone package and it will be discontinued in 2025 or later. Customers who have purchased Intel® Priority Support will continue to receive support. Please see Intel Inspector deprecation article for more information.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page