From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6042 invoked by alias); 5 Dec 2012 03:44:03 -0000 Received: (qmail 5931 invoked by uid 48); 5 Dec 2012 03:43:49 -0000 From: "guojiufu at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55602] New: Does not generate Error message for redefined macros Date: Wed, 05 Dec 2012 03:44:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: guojiufu at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg00423.txt.bz2 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; } --------------