Skip to content

C++ 20 compilation issue in rawtoaces_util/image_converter.cpp #250

@jfpanisset

Description

@jfpanisset

When compiling rawtoaces_util/image_converter.cpp with gcc 14 in C++ 20 mode, the following code fails:

#9 38.14 /opt/conan_home/d/b/rawtoe81215628ac43/b/src/src/rawtoaces_util/image_converter.cpp: In function 'rta::util::CameraIdentifier rta::util::get_camera_identifier(const OpenImageIO::v3_1
::ImageSpec&, const ImageConverter::Settings&)':
#9 38.14 /opt/conan_home/d/b/rawtoe81215628ac43/b/src/src/rawtoaces_util/image_converter.cpp:212:40: error: could not convert '{camera_make, camera_model}' from '<brace-enclosed initializer l
ist>' to 'rta::util::CameraIdentifier'
#9 38.14   212 |     return { camera_make, camera_model };
#9 38.14       |                                        ^
#9 38.14       |                                        |
#9 38.14       |                                        <brace-enclosed initializer list>

In C++ 20 used defined constructors prevent a class from being considered as an aggregate:

https://en.cppreference.com/w/cpp/20.html
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1008r1.pdf

The following patch against versions 2.0.0 allows the file to compile, but I have not tested it (yet) against earlier C++ versions:

--- src/rawtoaces_util/image_converter.cpp
+++ src/rawtoaces_util/image_converter.cpp
@@ -22,7 +22,8 @@
     std::string make;
     std::string model;

-    CameraIdentifier() = default;
+    // In C++ 20 a default constructure means the class is no longer an aggregate
+    // CameraIdentifier() = default;

     bool is_empty() const { return make.empty() && model.empty(); }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions