From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21569 invoked by alias); 22 Nov 2001 13:56:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 21555 invoked by uid 71); 22 Nov 2001 13:56:03 -0000 Date: Sun, 18 Nov 2001 16:50:00 -0000 Message-ID: <20011122135602.21554.qmail@sourceware.cygnus.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Baum, Nathan I" Subject: RE: preprocessor/4923: Concatenation appears to handle whitespace incorrectly Reply-To: "Baum, Nathan I" X-SW-Source: 2001-11/txt/msg00511.txt.bz2 List-Id: The following reply was made to PR preprocessor/4923; it has been noted by GNATS. From: "Baum, Nathan I" To: 'Zack Weinberg' Cc: gcc-gnats@gcc.gnu.org Subject: RE: preprocessor/4923: Concatenation appears to handle whitespace incorrectly Date: Thu, 22 Nov 2001 13:47:51 -0000 > From: Zack Weinberg [mailto:zack@codesourcery.com] > This behavior is correct. The concatenation operator acts before the > macro FOO is expanded. Ah yes, that makes sense, now that you point it out. > At that point the tokens on either side of ## are ")" and "def". > Pasting them together produces an invalid token, > ")def", which triggers undefined behavior - we choose to pretend the > ## never happened. Then "FOO ( abc )" gets expanded to produce "abc". > Since "abc" and "def" were not concatenated, cpp has to put a space > between them so they are interpreted sa separate tokens. Would it break existing programs if ## were to concatenate the two tokens regardless (in some later version of gcc)? I'd imagine that no sensible program would rely upon undefined behaviour, so it shouldn't. Presumeably, it'd have to throw the two tokens away and rescan the newly created string, but that doesn't _seem_ like a major problem (I don't know how CPP handles these things internally, so it might be). > gcc 3.x will warn you when this happens: > test.c:5:1: warning: pasting ")" and "def" does not give a valid preprocessing token Hmm. Shouldn't the message say 'concatenating' rather than 'pasting'?