Re: Blender: New error with min/max function not in scope

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

 



On 16/02/16 10:13 -0600, Richard Shaw wrote:
This seems like a pretty basic error in something that has worked fine for
a very long time. Is there anything in the GCC 6 update that would cause
this?

This no longer compiles with GCC 6:

#define max(a, b) (a > b ? a : b)
#include <stdlib.h>
int i = max(0,1);

The reason is that 'max' is used throughout the standard library, and
it's undefined behaviour to define a macro that clashes with any name
defined in the standard library. Previously <stdlib.h> was not
provided by GCC's C++ std::lib, so didn't #undef min and max. Now GCC
provides its own C++-conforming <stdlib.h> and so it does #undef min
and #undef max.

If that's the cause, the code might have been working fine but was
always relying on undefined behaviour.

I suggest #include <algorithm> and using std::max;
--
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