ICC bug: bogus warning "Use of offsetof() with non-POD type"

Issue #286 resolved
Dan Bonachea created an issue

This issue records a bug we've discovered in PGI v19.10 (a regression relative to previous versions), which causes a warning in compiling the UPC++ runtime (issue #284).

Example program:

#include <cstddef>
#include <type_traits>
#include <iostream>

#define T(t) do { \
    std::cout << "std::is_standard_layout<" #t ">::value = " \
              << std::is_standard_layout<t>::value << std::endl; \
    std::cout << "std::is_trivial<" #t ">::value = " \
              << std::is_trivial<t>::value << std::endl; \
    std::cout << "std::is_pod<" #t ">::value = " \
              << std::is_pod<t>::value << std::endl; \
  } while (0)

struct A {  // standard layout, trivial, POD
  int f;
};

struct B {  // standard layout, NOT trivial, NOT POD
  int f;
  B() {}
};

struct C {  // NOT standard layout, trivial, NOT POD
  int &f;
};

int main() {
  T(A); 
  std::cout << offsetof(A,f) << std::endl; // guaranteed to work by C++11-17 [support.types(.layout)]
  T(B); 
  std::cout << offsetof(B,f) << std::endl; // guaranteed to work by C++11-17 [support.types(.layout)]
  T(C); 
  #if CONDITIONAL
    // offsetof(non-standard layout) is undefined behavior until C++17 and conditionally supported after
    std::cout << offsetof(C,f) << std::endl;
  #endif
}

Demonstration of the regression on dirac (our x86-64 Linux cluster) where all the recent PGI versions are installed:

$ /usr/local/pkg/pgi/linux86-64/19.4/bin/pgc++ -std=c++11 -c pgi-offset.cpp
$ /usr/local/pkg/pgi/linux86-64/19.5/bin/pgc++ -std=c++11 -c pgi-offset.cpp 
$ /usr/local/pkg/pgi/linux86-64/19.7/bin/pgc++ -std=c++11 -c pgi-offset.cpp 
$ /usr/local/pkg/pgi/linux86-64/19.9/bin/pgc++ -std=c++11 -c pgi-offset.cpp 
$ /usr/local/pkg/pgi/linux86-64/19.10/bin/pgc++ -std=c++11 -c pgi-offset.cpp 
"pgi-offset.cpp", line 31: warning: offsetof applied to non-POD types is
          nonstandard
    std::cout << offsetof(B,f) << std::endl; // guaranteed to work by C++11-17 [support.types(.layout)]
                 ^

$ /usr/local/pkg/pgi/linux86-64/19.10/bin/pgc++ --version

pgc++ 19.10-0 LLVM 64-bit target on x86-64 Linux -tp nehalem 
PGI Compilers and Tools
Copyright (c) 2019, NVIDIA CORPORATION.  All rights reserved.

This new warning behavior represents a regression / bug for two reasons:

  1. The warning message text is wrong/misleading: The C++ specs for offsetof(type, member-designator) in [support.types(.layout)] require it to work for any type that is standard layout. Standard layout is NOT the same thing as POD - see C++ section [class] for details. In a nutshell, POD means Standard Layout and Trivial, so Standard Layout is a superset of POD.
  2. offsetof is required to work for Standard Layout types that are not POD In the example code, class B is Standard Layout (but not POD) and therefore required to be supported. Only classes that fall outside Standard Layout lead to undefined (until C++17) or conditionally supported behavior (after C++17) when passed to offsetof()

I will be reporting this external bug to Portland Group.

Comments (15)

  1. Dan Bonachea reporter

    Response from PGI:

    Thanks, the warning message is erroneously emitted. Our resident C++ expert is at supercomputing this week, but I’ve filed TPR #27850 to track the problem.

    Interestingly I don’t see the warning in our internal development version, so I’ll need to confirm if we’ve already addressed this. But in any case I will try to prioritize this to be fixed before the next release.

    Kind regards, Alex Globus

  2. Paul Hargrove

    Confirmed w/ ICC-19.0.5.281 as well:

    {phargrov@pcp-d-5 ~}$ icpc --version
    icpc (ICC) 19.0.5.281 20190815
    Copyright (C) 1985-2019 Intel Corporation.  All rights reserved.
    
    {phargrov@pcp-d-5 ~}$ icpc issue286.cpp -Wextra
    issue286.cpp(31): warning #1875: offsetof applied to non-POD (Plain Old Data) types is nonstandard
        std::cout << offsetof(B,f) << std::endl; // guaranteed to work by C++11-17 [support.types(.layout)]
                     ^
    
  3. Dan Bonachea reporter
    • changed status to open

    This issue remains open to track the continuing external bug in PGI.

    It will be updated/resolved when PGI releases a fix

  4. Dan Bonachea reporter

    Update from PGI on this:

    This expected to be fixed in 20.1, which we’re hoping to have released around the end of the month. No further action needed, though if you could re-test and confirm once 20.1 is out.

  5. Dan Bonachea reporter

    I've also now reported the matching defect to Intel through my support account on their website, where it was assigned support request number 04502486

  6. Dan Bonachea reporter

    Response from Intel is below:


    C++ Compiler Next Generation framework (ICC NextGen) shipped in Intel® Parallel Studio XE 2020 package. For more information please refer to the Porting Guide: https://software.intel.com/en-us/articles/early-documentation-for-intel-c-compiler-based-on-the-modern-llvm-framework

    I have reproduced your issue with the latest 19.1 ICC Classic (19.1 20200128 build).

    icpc -Wextra -std=c++11 -c issue286.cc   issue286.cc(43): warning #1875: offsetof applied to non-POD (Plain Old Data) types is nonstandard std::cout << "B" << offsetof(B,f) << std::endl; // guaranteed to work by C++11-17 [support.types(.layout)]
    

    However, the issue is not reproducible with ICC NextGen:

    icx -Wextra -std=c++11 -c -qnextgen issue286.cc
    

    Since it is an issue with warning, the impact is low and the ICC NextGen doesn't have this bug, I am going to close this case as resolved. Please feel free to let me know if you have any further questions and need an assistance from my side.

    Sign in to view and update your request or to get additional information. You can also reply to this email with questions or comments.

    Regards,

    Alina Intel Developer Products Support


    In a nutshell they don't consider it worth fixing, probably because all their development effort is on their replacement compiler... which FWIW is not yet recommended for end users or on by default. Here's a quote from their NextGen porting guide (dated one month ago):

    ICC Classic (icc/icpc/icl drivers) will remain Intel’s recommended production compiler AND THE DEFAULT compiler until ICC NextGen has performance and features superior to ICC Classic. In the future, when ICC NextGen functionality and performance equivalence or better against ICC Classic is achieved, Intel may change the default for ICC to be ICC NextGen, instead of, ICC Classic. We have no set timeline for this transition as it is conditional on reaching equivalence or better than current ICC Classic technology. Going forward BOTH ICC Classic and ICC NextGen compilers will be provided in Intel Compiler packages. Compiler options will be used to select one or the other compilers.

  7. Dan Bonachea reporter

    Intel has re-opened this issue in their support database, I guess they changed their minds:

    This bug is escalated to the development team (CMPLRIL0-32503). It should be fixed in the upcoming compiler updates.

  8. Dan Bonachea reporter

    Intel reports this has now been fixed:

    Alina from Intel Support responded Today 12:14 AM
    The fix for this issue will be included in future Parallel Studio releases. The fix is also available in oneAPI HPC Toolkit compilers. It is currently in beta so you can early check this fix right now.

    Please, refer to Intel® oneAPI HPC Toolkit(Beta) page for more information about it and getting an access to the package.

    Since the fix is available, I am going to close this case as resolved. Please feel free to let me know if you have any further questions and need assistance from my side.

  9. Paul Hargrove

    The "future Parallel Studio release" has yet to arrive.
    The 2020.4.304 (aka 19.1.3.304) version of icpc still warns.

    {phargrov@pcp-d-5 ~}$ icpc --version
    icpc (ICC) 19.1.3.304 20200925
    Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.
    
    {phargrov@pcp-d-5 ~}$ icpc --version
    icpc (ICC) 19.1.3.304 20200925
    Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.
    
    {phargrov@pcp-d-5 ~}$ icpc issue286.cpp -Wextra
    issue286.cpp(31): warning #1875: offsetof applied to non-POD (Plain Old Data) types is nonstandard
        std::cout << offsetof(B,f) << std::endl; // guaranteed to work by C++11-17 [support.types(.layout)]
                     ^
    
    {phargrov@pcp-d-5 ~}$ icpc issue286.cpp -Wextra -std=c++17
    issue286.cpp(31): warning #1875: offsetof applied to non-POD (Plain Old Data) types is nonstandard
        std::cout << offsetof(B,f) << std::endl; // guaranteed to work by C++11-17 [support.types(.layout)]
                     ^
    
  10. Paul Hargrove

    The Intel issue is resolved in the 2020.1.2 compiler:

    {phargrov@pcp-d-5 ~}$ icpc --version
    icpc (ICC) 2021.1.2 20201208
    Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.
    
    {phargrov@pcp-d-5 ~}$ icpc -Wextra issue286.cpp
    {phargrov@pcp-d-5 ~}$ icpc -Wextra issue286.cpp -std=c++11
    {phargrov@pcp-d-5 ~}$ icpc -Wextra issue286.cpp -std=c++14
    {phargrov@pcp-d-5 ~}$ icpc -Wextra issue286.cpp -std=c++17
    {phargrov@pcp-d-5 ~}$ icpc -Wextra issue286.cpp -std=c++2a
    

    vs the 2020.4.304 (akak 19.1.3.304) version:

    {phargrov@pcp-d-5 ~}$ icpc --version
    icpc (ICC) 19.1.3.304 20200925
    Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.
    
    {phargrov@pcp-d-5 ~}$ icpc -Wextra issue286.cpp
    issue286.cpp(31): warning #1875: offsetof applied to non-POD (Plain Old Data) types is nonstandard
        std::cout << offsetof(B,f) << std::endl; // guaranteed to work by C++11-17 [support.types(.layout)]
                     ^
    
  11. Paul Hargrove

    Closing since we believe the latest available release of every supported compiler family now exhibits correct behavior on the reproducer.

  12. Log in to comment