Re: Help with Rawhide build error with GCC 6.0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
--
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
http://lists.fedoraproject.org/admin/lists/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux