public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/10212: Preprocessor ## problem
@ 2003-03-25 18:16 rwgk
  0 siblings, 0 replies; 4+ messages in thread
From: rwgk @ 2003-03-25 18:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10212
>Category:       c++
>Synopsis:       Preprocessor ## problem
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 25 18:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Ralf W. Grosse-Kunstleve
>Release:        cvs gcc-3_3-branch 2003-03-25 approx. 08:00AM PST
>Organization:
>Environment:
Redhat 7.3 on Pentium
>Description:
The code below fails to compile with current cvs gcc 3.3:

% cat z.cpp
# define BOOST_PYTHON_INPLACE_OPERATOR(op)                      \
  template <class R>                                            \
  inline R                                                      \
  operator##op(R const& a, R const& b )                         \
  {                                                             \
      return a+b;                                               \
  }

BOOST_PYTHON_INPLACE_OPERATOR(+)

% gcc --version
gcc (GCC) 3.3 20030325 (prerelease)
% gcc -c z.cpp
z.cpp:9:32: pasting "operator" and "+" does not give a valid preprocessing token
% echo $status
1

The original code compiles with a large number of compilers incl. several EDG-based, Visual C++ and gcc 2.96 - gcc 3.2.2. Older gcc's issue a warning which can be suppressed with -w.
>How-To-Repeat:
See description.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c++/10212: Preprocessor ## problem
@ 2003-03-26 19:26 Martin Sebor
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Sebor @ 2003-03-26 19:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/10212; it has been noted by GNATS.

From: Martin Sebor <sebor@roguewave.com>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/10212: Preprocessor ## problem
Date: Wed, 26 Mar 2003 11:47:53 -0700

 zack@gcc.gnu.org wrote:
 > Synopsis: Preprocessor ## problem
 > 
 > State-Changed-From-To: open->closed
 > State-Changed-By: zack
 > State-Changed-When: Tue Mar 25 18:32:08 2003
 > State-Changed-Why:
 >     Not a bug.  C++98 [cpp.concat]/3:
 >     
 >       If the result [of pasting two tokens together] is not 
 >       a valid preprocessing token, the behavior is undefined.  
 >     
 >     GCC chooses to issue a hard error.
 >     
 >     The ## in the macro in your example is totally unnecessary.  Remove it and your program will work correctly both with GCC 3.3 and with all other compilers.
 
 FWIW, I certainly see value in making the compiler as strict as
 possible (e.g., with -pedantic) so that programs first compiled
 with gcc are easily portable to other platforms. But I also see
 value in making gcc as permissive as possible (e.g., with another
 option or by default) so that programs first compiled with other,
 less restrictive compilers, compile successfully when ported to
 gcc.
 
 In this particular case, all of EDG (all its derivatives, such
 as Intel C++), IBM VAC++, and SunPro compile the code without
 complaint and with the result expected by the submitter, so it
 would not, IMHO, be entirely inappropriate for gcc to do so as
 well in the interest of portability.
 
 Regards
 Martin
 
 > 
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10212
 


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

* Re: c++/10212: Preprocessor ## problem
@ 2003-03-25 18:33 zack
  0 siblings, 0 replies; 4+ messages in thread
From: zack @ 2003-03-25 18:33 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, rwgk

Synopsis: Preprocessor ## problem

State-Changed-From-To: open->closed
State-Changed-By: zack
State-Changed-When: Tue Mar 25 18:32:08 2003
State-Changed-Why:
    Not a bug.  C++98 [cpp.concat]/3:
    
      If the result [of pasting two tokens together] is not 
      a valid preprocessing token, the behavior is undefined.  
    
    GCC chooses to issue a hard error.
    
    The ## in the macro in your example is totally unnecessary.  Remove it and your program will work correctly both with GCC 3.3 and with all other compilers.

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


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

* Re: c++/10212: Preprocessor ## problem
@ 2003-03-25 18:26 Falk Hueffner
  0 siblings, 0 replies; 4+ messages in thread
From: Falk Hueffner @ 2003-03-25 18:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/10212; it has been noted by GNATS.

From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: rwgk@cci.lbl.gov
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/10212: Preprocessor ## problem
Date: 25 Mar 2003 19:09:40 +0100

 rwgk@cci.lbl.gov writes:
 
 > The code below fails to compile with current cvs gcc 3.3:
 > 
 > % cat z.cpp
 > # define BOOST_PYTHON_INPLACE_OPERATOR(op)                      \
 >   template <class R>                                            \
 >   inline R                                                      \
 >   operator##op(R const& a, R const& b )                         \
 >   {                                                             \
 >       return a+b;                                               \
 >   }
 > 
 > BOOST_PYTHON_INPLACE_OPERATOR(+)
 > 
 > % gcc --version
 > gcc (GCC) 3.3 20030325 (prerelease)
 > % gcc -c z.cpp
 > z.cpp:9:32: pasting "operator" and "+" does not give a valid preprocessing token
 > % echo $status
 > 1
 > 
 > The original code compiles with a large number of compilers
 > incl. several EDG-based, Visual C++ and gcc 2.96 - gcc 3.2.2. Older
 > gcc's issue a warning which can be suppressed with -w.
 
 Well, gcc is right here, it's simply not valid code. Since C++ allows
 whitespace between "operator" and the operator token, you could just
 leave it off.
 
 -- 
 	Falk


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

end of thread, other threads:[~2003-03-26 18:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-25 18:16 c++/10212: Preprocessor ## problem rwgk
2003-03-25 18:26 Falk Hueffner
2003-03-25 18:33 zack
2003-03-26 19:26 Martin Sebor

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).