[Bug c++/55602] New: Does not generate Error message for redefined macros

guojiufu at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Dec 5 03:44:00 GMT 2012


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

             Bug #: 55602
           Summary: Does not generate Error message for redefined macros
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: guojiufu@gmail.com


gcc and g++ generate warning message(do not generate any information if there
is '#pragma GCC system_header' is the header) instead an error message for
redefined macros. While in standard it seems require an error. 

Second paragraph of section "Macro replacement" in C standard:
--------
An identifier currently defined as an object-like macro shall not be redefined
by another #define preprocessing directive unless the second definition is an
object-like macro definition and the two replacement lists are identical.
Likewise, an identifier currently defined as a function-like macro shall not be
redefined by another #define preprocessing directive unless the second
definition is a function-like macro definition that has the same number and
spelling of parameters, and the two replacement lists are identical.
----------
C++ standard: Second paragraph of section "Macro replacement"
---------
An identifier currently defined as an object-like macro may be redefined by
another #define preprocessing directive provided that the second definition is
an object-like macro definition and the two replacement lists are identical,
otherwise the program is ill-formed. Likewise, an identifier currently defined
as a function-like macro may be redefined by another #define preprocessing
directive provided that the second definition is a function-like macro
definition that has the same number and spelling of parameters, and the two
replacement lists are identical, otherwise the program is ill-formed.
------------------


case:
a.h
----------------
#define A 1
#define A 2
---------------

a.c
---------------
#include "a.h"

int main(){
  return A;
}
--------------



More information about the Gcc-bugs mailing list