[Bug libstdc++/69782] [6 Regression] defining min() macro causes thousand of lines of error messages

2016-03-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69782

--- Comment #8 from Jonathan Wakely  ---
(In reply to Jakub Jelinek from comment #7)
> So is the plan to uglify all
> find libstdc++-v3/include -type f | xargs grep '[^a-zA-Z_]\(min\|max\)(' |
> wc -l
> 461
> with ()s around min/max or whatever id-expression it appears at the end of?

I started doing that, and it made me want to hit myself in the face with a
hammer.

Adding a header that #undefs the macros and including it everywhere necessary
is a much smaller patch, and doesn't obfuscate hundreds of valid uses of
min/max functions in the library. It also means users can call the std min/max
functions without parentheses because any macros have been removed. It doesn't
allow people to continue using their undefined macros, but those people are
immoral anyway.

> For 6.x or just 7.x?

I find it hard to care about code with min/max macros.

[Bug libstdc++/69782] [6 Regression] defining min() macro causes thousand of lines of error messages

2016-03-14 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69782

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek  ---
So is the plan to uglify all
find libstdc++-v3/include -type f | xargs grep '[^a-zA-Z_]\(min\|max\)(' | wc
-l
461
with ()s around min/max or whatever id-expression it appears at the end of?
For 6.x or just 7.x?

[Bug libstdc++/69782] [6 Regression] defining min() macro causes thousand of lines of error messages

2016-03-13 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69782

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |6.0

[Bug libstdc++/69782] [6 Regression] defining min() macro causes thousand of lines of error messages

2016-02-12 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69782

--- Comment #1 from Markus Trippelsdorf  ---
The fix is easy in this case, just #include  after the macro
definition.

luminance-hdr-2.3.0/src/HdrCreation/robertson02.cpp 
From  
 30 #include "arch/math.h"  
 31 #include "arch/minmax.h"
 32 
 33 #include   

To 
 30 #include "arch/minmax.h"
 31 #include "arch/math.h"  
 32 
 33 #include 

[Bug libstdc++/69782] [6 Regression] defining min() macro causes thousand of lines of error messages

2016-02-12 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69782

Manuel López-Ibáñez  changed:

   What|Removed |Added

 CC||manu at gcc dot gnu.org

--- Comment #3 from Manuel López-Ibáñez  ---
(In reply to Jonathan Wakely from comment #2)
> I assume clang does it by not having header guards in its __undef_min_max
> file, so that it can be re-included by any header and redo the #undefs.

Let's do the same, no?

> I'm almost tempted to make it #error not #warning, to teach people a lesson
> ;-)

Well, they will get an error if they use -Werror.

[Bug libstdc++/69782] [6 Regression] defining min() macro causes thousand of lines of error messages

2016-02-12 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69782

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2016-02-12
   Assignee|unassigned at gcc dot gnu.org  |redi at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Jonathan Wakely  ---
This is undefined behaviour, really egregious undefined behaviour.

The code compiled before because  includes  which
does
#undef min
#undef max
to remove the silly macro before doing anything else. Now that  include
 those #undefs come too early to help.

I assume clang does it by not having header guards in its __undef_min_max file,
so that it can be re-included by any header and redo the #undefs.

I'm almost tempted to make it #error not #warning, to teach people a lesson ;-)

[Bug libstdc++/69782] [6 Regression] defining min() macro causes thousand of lines of error messages

2016-02-12 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69782

Martin Sebor  changed:

   What|Removed |Added

 CC||msebor at gcc dot gnu.org

--- Comment #4 from Martin Sebor  ---
FWIW, while C++ doesn't allow programs to define min and max as macros, lots of
C code does it.  When that code happens to be in a header, including that
header in a C++ program causes all kinds of grief.  Sometimes, fixing the
header is easy.  Other times, for instance when the header is a system one, it
can be less than trivial.  A fairly easy way to avoid having to deal with the
problem in libstdc++ is to enclose every call to min and max in public
libstdc++ headers in parentheses: z = (min)(x, y).

[Bug libstdc++/69782] [6 Regression] defining min() macro causes thousand of lines of error messages

2016-02-12 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69782

--- Comment #6 from Jonathan Wakely  ---
(In reply to Jonathan Wakely from comment #5)
> That doesn't help for std::numeric_limits::min()

Martin corrected me, (numeric_limits::min)() will work.

[Bug libstdc++/69782] [6 Regression] defining min() macro causes thousand of lines of error messages

2016-02-12 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69782

--- Comment #5 from Jonathan Wakely  ---
(In reply to Martin Sebor from comment #4)
> it can be less than trivial.  A fairly easy way to avoid having to deal with
> the problem in libstdc++ is to enclose every call to min and max in public
> libstdc++ headers in parentheses: z = (min)(x, y).

That doesn't help for std::numeric_limits::min()