Skip to content

Commit

Permalink
ICC 19.1.2: CXX17 Work-Arounds (Variant)
Browse files Browse the repository at this point in the history
The `Attribute` constructors with implicit variant conversion
sometimes do not work in ICC 19.1.2.

```
openPMD-api/src/RecordComponent.cpp(226): error: no instance of constructor "openPMD::Attribute::Attribute" matches the argument list
            argument types are: (openPMD::Extent)
                  Attribute a(getExtent());
                              ^
openPMD-api/include/openPMD/backend/Attribute.hpp(50): note: this candidate was rejected because arguments do not match
  class Attribute :
        ^
openPMD-api/include/openPMD/backend/Attribute.hpp(50): note: this candidate was rejected because arguments do not match
  class Attribute :
        ^
openPMD-api/include/openPMD/backend/Attribute.hpp(79): note: this candidate was rejected because arguments do not match
      Attribute(resource r) : Variant(std::move(r))
      ^
```

Same work-around as for NVCC in  openPMD#1103
  • Loading branch information
ax3l committed Dec 8, 2021
1 parent 680a011 commit 540ecc8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/IO/HDF5/HDF5IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,12 @@ HDF5IOHandlerImpl::createDataset(Writable* writable,
std::cerr << "[HDF5] Datatype::UNDEFINED caught during dataset creation (serial HDF5)" << std::endl;
d = Datatype::BOOL;
}
Attribute a(0);

// note: due to a C++17 issue with ICC 19.1.2 we write the
// T value to variant conversion explicitly
// https://github.com/openPMD/openPMD-api/pull/...
// Attribute a(0);
Attribute a(static_cast<Attribute::resource>(0));
a.dtype = d;
std::vector< hsize_t > dims;
std::uint64_t num_elements = 1u;
Expand Down
6 changes: 5 additions & 1 deletion src/RecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ RecordComponent::flush(std::string const& name)
aWrite.resource = m_constantValue->getResource();
IOHandler()->enqueue(IOTask(this, aWrite));
aWrite.name = "shape";
Attribute a(getExtent());
// note: due to a C++17 issue with ICC 19.1.2 we write the
// T value to variant conversion explicitly
// https://github.com/openPMD/openPMD-api/pull/...
// Attribute a(getExtent());
Attribute a(static_cast<Attribute::resource>(getExtent()));
aWrite.dtype = a.dtype;
aWrite.resource = a.getResource();
IOHandler()->enqueue(IOTask(this, aWrite));
Expand Down
6 changes: 5 additions & 1 deletion test/CoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ TEST_CASE( "versions_test", "[core]" )

TEST_CASE( "attribute_dtype_test", "[core]" )
{
Attribute a = Attribute(static_cast< char >(' '));
// note: due to a C++17 issue with ICC 19.1.2 we write the
// T value to variant conversion explicitly
// https://github.com/openPMD/openPMD-api/pull/...
// Attribute a = Attribute(static_cast< char >(' '));
Attribute a = Attribute(static_cast<Attribute::resource>(static_cast< char >(' ')));
REQUIRE(Datatype::CHAR == a.dtype);
a = Attribute(static_cast< unsigned char >(' '));
REQUIRE(Datatype::UCHAR == a.dtype);
Expand Down

0 comments on commit 540ecc8

Please sign in to comment.