Try this?

https://github.com/OpenImageIO/oiio/pull/1339 
<https://github.com/OpenImageIO/oiio/pull/1339>



---------------------- src/libOpenImageIO/CMakeLists.txt ----------------------
index 6994dfd..fd6e4d1 100644
@@ -13,6 +13,10 @@ if (NOT USE_EXTERNAL_PUGIXML)
           ../include/OpenImageIO/pugixml.hpp
           ../include/OpenImageIO/pugixml.cpp
     )
+    if (CMAKE_COMPILER_IS_GNUCC AND NOT ${GCC_VERSION} VERSION_LESS 6.0)
+        set_source_files_properties (formatspec.cpp xmp.cpp
+                                     PROPERTIES COMPILE_FLAGS 
-Wno-error=placement-new)
+    endif ()
 endif()
 
 set (libOpenImageIO_srcs deepdata.cpp exif.cpp formatspec.cpp imagebuf.cpp


> On Feb 3, 2016, at 11:15 AM, Richard Shaw <[email protected]> wrote:
> 
> Here's the next suggestion I got (with correction in another email):
> 
> On 03/02/16 10:59 -0600, Richard Shaw wrote:
> With the release of GCC 6.0 in Rawhide I'm having a build
> warning/error[1,2] with OpenImageIO I'm not sure what to do with (other
> than adding a flag to ignore it).
> 
> tl;dr either add -Wno-error=placement-new for now or try the
> workaround at the bottom of this mail.
> 
> Upstream is looking into it but currently thinks that the pugixml API is
> requiring a method that GCC 6.0 doesn't like:
> 
> No, the code is trying to place a large object in a tiny buffer, and
> GCC issues a warning about that, because it looks suspect. Because the
> package uses -Werror (which I won't rant about now) that warning
> becomes an error and so breaks the build.
> 
> It looks like the code is possibly safe though, meaning the warning is
> a false-positive. The code appears to be using an emulated form of C99
> flexible-array member (which isn't supported in standard C++). I
> assume there is a 1-byte array at the end of the object, and then they
> over-allocating for the object so they can store something else in the
> location beginning at the 1-byte array e.g.
> 
> #include <stdlib.h>
> 
> struct X {
>  enum Type { Int, Double };
>  Type type;
>  char data[1];
> };
> 
> int main()
> {
>  X* p = (X*)malloc(sizeof(X) + sizeof(double) - 1);
>  *(double*)p->data = 1.0;
>  p->type = X::Double;
> }
> 
> (This example ignores alignment requirements, so isn't OK, the real
> code in OpenImageIO might be OK).
> 
> I'll take a closer look, but if this is doing something reasonable
> then we'll need to make GCC's warning smarter, so it allows cases like
> this.
> 
> /builddir/build/BUILD/oiio-Release-1.6.9/src/include/OpenImageIO/pugixml.cpp:5143:58:
> error: placement new constructing an object of type
> 'OpenImageIO::v1_6::pugi::impl::xml_document_struct' and size '44' in a
> region of type 'char [1]' and size '1' [-Werror=placement-new]
>   _root = new (page->data) impl::xml_document_struct(page);
> 
> A workaround would be to make it too hard for the compiler to see the
> problem:
> 
>  void* ptr = page->data;
>  _root = new (ptr) impl::xml_document_struct(page);
> 
> This way GCC doesn't see that the address refers to a 1-byte array.
> 
> --- 
> 
> Oops, I pasted the wrong version of the example. To reproduce the same
> warning the line above should be:
> 
>  double* d = new (p->data) double(1.0);
> 
> ---
> 
> Thanks,
> Richard
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

--
Larry Gritz
[email protected]


_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to