This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/60491] New: Macros defined in sys/sysmacros.h pulled in by <iterator> even in -std=c++11


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60491

            Bug ID: 60491
           Summary: Macros defined in sys/sysmacros.h pulled in by
                    <iterator> even in -std=c++11
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: will at wmitchell dot net

The following minimal test case:

#include <iterator>
void minor(int row, int col);

fails to compile with gcc 4.8.2 even when -std=c++11 is passed.

$ g++ -std=c++11 -pedantic test.cpp 
test.cpp:2:28: error: macro "minor" passed 2 arguments, but takes just 1
 void minor(int row, int col);
                            ^
test.cpp:2:6: error: variable or field âminorâ declared void
 void minor(int row, int col);
      ^
$

The problem is that <iterator> pulls in sys/sysmacros.h, which defines:

# define major(dev) gnu_dev_major (dev)
# define minor(dev) gnu_dev_minor (dev)
# define makedev(maj, min) gnu_dev_makedev (maj, min)


There is an old, related bug at
https://bugzilla.redhat.com/show_bug.cgi?id=130601 closed as WONTFIX

I'm filing again because my expectation is that -std=c++11 wouldn't pull in
these macros. Obviously these are not reserved words by the standard, so I
don't think pulling in part of the standard library should define these macros.

sys/sysmacros.h may also be pulled in by other standard library headers, I have
not tested which ones do or do not.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]