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

Reply via email to