public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* preprocessor/5234: Variable arguments list in macro fail with another macro inclusion
@ 2002-01-01 10:46 david.taillandier
  0 siblings, 0 replies; 4+ messages in thread
From: david.taillandier @ 2002-01-01 10:46 UTC (permalink / raw)
  To: gcc-gnats


>Number:         5234
>Category:       preprocessor
>Synopsis:       Variable arguments list in macro fail with another macro inclusion
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 01 10:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     David TAILLANDIER
>Release:        gcc version 2.95.3 20010315/djgpp (release)
>Organization:
>Environment:
Win95 / MS-DOS 6 / Win98
>Description:
In one case, clearly identified, when using variable
arguments list macro with another macro inside the first
one, the preprocessing process (duh) gives an error.
See sample, it's very simple.

Hope I don't miss something.
david.taillandier@domainename.com
>How-To-Repeat:

#include <stdio.h>

#define _(text_to_translate)    text_to_translate

#define    PROBLEM_HERE( text, vargs... )         printf( text _("ending string\n"),  ## vargs )
#define NO_PROBLEM_HERE( text, vargs... )         printf( text _("ending string\n") , ## vargs )
#define        NOR_HERE( text, vargs... )         printf( text, ## vargs )

/* the only difference is the space before the comma witch is not present in PROBLEM_HERE */

int
main( void )
{
       PROBLEM_HERE( "123" );
    NO_PROBLEM_HERE( "456" );
           NOR_HERE( "789" );

    return 0;
}
>Fix:
I don't know how to fix this, sorry.
But a workaround is to add a space before the comma
preceding the ##
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: preprocessor/5234: Variable arguments list in macro fail with another macro inclusion
@ 2002-01-01 11:42 rodrigc
  0 siblings, 0 replies; 4+ messages in thread
From: rodrigc @ 2002-01-01 11:42 UTC (permalink / raw)
  To: david.taillandier, gcc-bugs, gcc-prs, nobody

Synopsis: Variable arguments list in macro fail with another macro inclusion

State-Changed-From-To: open->closed
State-Changed-By: rodrigc
State-Changed-When: Tue Jan  1 11:42:41 2002
State-Changed-Why:
    Fixed in gcc 3.0

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5234


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: preprocessor/5234: Variable arguments list in macro fail with another macro inclusion
@ 2002-01-01 11:16 Zack Weinberg
  0 siblings, 0 replies; 4+ messages in thread
From: Zack Weinberg @ 2002-01-01 11:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR preprocessor/5234; it has been noted by GNATS.

From: Zack Weinberg <zack@codesourcery.com>
To: david.taillandier@domainename.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/5234: Variable arguments list in macro fail with another macro inclusion
Date: Tue, 1 Jan 2002 11:08:25 -0800

 On Tue, Jan 01, 2002 at 06:36:32PM -0000, david.taillandier@domainename.com wrote:
 
 
 > #define    PROBLEM_HERE( text, vargs... ) \
         printf( text _("ending string\n"),  ## vargs )
 > #define NO_PROBLEM_HERE( text, vargs... ) \
         printf( text _("ending string\n") , ## vargs )
 
 You've run afoul of a clearly documented misfeature of gcc 2.x.
 
 	`##' before a rest argument that is empty discards the
 	preceding sequence of non-whitespace characters from the macro
 	definition. (If another macro argument precedes, none of it is
 	discarded.)
 
 What that means is,
 
 	PROBLEM_HERE ( "123" )
 
 expands to
 
 	printf ( "123" _ ( "ending )
 
 which is obviously not what you want.  The space before the comma is
 mandatory if you want your code to work with gcc 2.x.
 
 In gcc 3.0 we changed this extension so that only the comma gets
 deleted.  Your example code works correctly with that version of the
 compiler.
 
 zw


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: preprocessor/5234: Variable arguments list in macro fail with another macro inclusion
@ 2002-01-01 10:56 Andrew Pinski
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Pinski @ 2002-01-01 10:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR preprocessor/5234; it has been noted by GNATS.

From: Andrew Pinski <pinskia@physics.uc.edu>
To: david.taillandier@domainename.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/5234: Variable arguments list in macro fail with another macro inclusion
Date: Tue, 1 Jan 2002 13:51:03 -0500

 This has been fixed in gcc 3.0.3 and gcc 3.1
 Thanks,
 Andrew Pinski
 
 PS here is what I get when I run the preprocessor on the source (with 
 the include removed):
 
 # 1 "myc.c"
 # 1 "<built-in>"
 # 1 "<command line>"
 # 1 "myc.c"
 # 9 "myc.c"
 int
 main( void )
 {
         printf( "123" "ending string\n" );
      printf( "456" "ending string\n" );
             printf( "789" );
 
      return 0;
 }
 
 
 On Tuesday, January 1, 2002, at 01:36 , 
 david.taillandier@domainename.com wrote:
 
 >
 >> Number:         5234
 >> Category:       preprocessor
 >> Synopsis:       Variable arguments list in macro fail with another 
 >> macro inclusion
 >> Confidential:   no
 >> Severity:       non-critical
 >> Priority:       medium
 >> Responsible:    unassigned
 >> State:          open
 >> Class:          rejects-legal
 >> Submitter-Id:   net
 >> Arrival-Date:   Tue Jan 01 10:46:01 PST 2002
 >> Closed-Date:
 >> Last-Modified:
 >> Originator:     David TAILLANDIER
 >> Release:        gcc version 2.95.3 20010315/djgpp (release)
 >> Organization:
 >> Environment:
 > Win95 / MS-DOS 6 / Win98
 >> Description:
 > In one case, clearly identified, when using variable
 > arguments list macro with another macro inside the first
 > one, the preprocessing process (duh) gives an error.
 > See sample, it's very simple.
 >
 > Hope I don't miss something.
 > david.taillandier@domainename.com
 >> How-To-Repeat:
 >
 > #include <stdio.h>
 >
 > #define _(text_to_translate)    text_to_translate
 >
 > #define    PROBLEM_HERE( text, vargs... )         printf( text 
 > _("ending string\n"),  ## vargs )
 > #define NO_PROBLEM_HERE( text, vargs... )         printf( text 
 > _("ending string\n") , ## vargs )
 > #define        NOR_HERE( text, vargs... )         printf( text, ## 
 > vargs )
 >
 > /* the only difference is the space before the comma witch is not 
 > present in PROBLEM_HERE */
 >
 > int
 > main( void )
 > {
 >        PROBLEM_HERE( "123" );
 >     NO_PROBLEM_HERE( "456" );
 >            NOR_HERE( "789" );
 >
 >     return 0;
 > }
 >> Fix:
 > I don't know how to fix this, sorry.
 > But a workaround is to add a space before the comma
 > preceding the ##
 >> Release-Note:
 >> Audit-Trail:
 >> Unformatted:
 >
 >
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-01-01 19:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-01 10:46 preprocessor/5234: Variable arguments list in macro fail with another macro inclusion david.taillandier
2002-01-01 10:56 Andrew Pinski
2002-01-01 11:16 Zack Weinberg
2002-01-01 11:42 rodrigc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).