public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/30363]  New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
@ 2007-01-04  3:24 fnf at specifixinc dot com
  2007-01-07  1:09 ` [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: fnf at specifixinc dot com @ 2007-01-04  3:24 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3618 bytes --]

Given the following test case:

  #define f(x, y) "x y"

  extern void abort (void);

  int main ()
  {
    const char *str1 = f("a", "\"a\"");
    const char *str2 = f( \t, " \t");

    if (strcmp (str1, "\"a\" \"\\\"a\\\"\""))
      abort ();
    if (strcmp (str2, "\t \" \\t\""))
      abort ();
    return 0;
  }

Gcc 2.95.3 will accept it and do the right thing:

  $ gcc -v
  Reading specs from /opt/local/fsf/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/specs
  gcc version 2.95.3 20010315 (release)
  $ gcc -traditional-cpp -o macroargs macroargs.c
  $ ./macroargs
  $

Current gcc 4.X fails to accept this code.  For example, using the Fedora Core
6 compiler:

  $ /usr/bin/gcc -v
  Using built-in specs.
  Target: i386-redhat-linux
  Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic
--host=i386-redhat-linux
  Thread model: posix
  gcc version 4.1.1 20061011 (Red Hat 4.1.1-30)
  $ /usr/bin/gcc -traditional-cpp -o macroargs macroargs.c
  macroargs.c: In function ‘main’:
  macroargs.c:7: error: expected ‘,’ or ‘;’ before ‘a’
  macroargs.c:7: error: stray ‘\’ in program
  macroargs.c:7: error: missing terminating " character
  macroargs.c:8: error: stray ‘\’ in program
  macroargs.c:12: error: ‘str2’ undeclared (first use in this function)
  macroargs.c:12: error: (Each undeclared identifier is reported only once
  macroargs.c:12: error: for each function it appears in.)

The attached patch (also posted to gcc-patches) will fix it, although
it's handling of quoted arguments is not exactly identical to gcc
2.95.3.  Notice the difference between the test case above, and the
test case included with the patch.

Here is an example of a patched gcc's behavior:

  $ /opt/specifix/experimental/bin/gcc -v
  Using built-in specs.
  Target: i686-pc-linux-gnu
  Configured with: /src/specifix/experimental/src/gcc/configure
--enable-languages=c,c++,fortran --prefix=/opt/specifix/experimental
--disable-werror --disable-bootstrap --with-mpfr=/opt/specifix/experimental
--with-gmp=/opt/specifix/experimental --cache-file=/dev/null
--srcdir=/src/specifix/experimental/src/gcc
  Thread model: posix
  gcc version 4.3.0 20061231 (experimental)
  $ /opt/specifix/experimental/bin/gcc -traditional-cpp -o macroargs
macroargs.c
  $

Note however that the above test case WILL abort if run, while the
test case included with the patch will not, due to the handling of
leading and trailing whitespace in macro args.  See the code inside
"#if 0 ... #endif" in the patch and the associated comments.  Either the
current gcc testsuite is wrong in how it tests for this whitespace, or
gcc 2.95.3 is wrong.  It's not clear to me which behavior is more correct.


-- 
           Summary: Support for -traditional-cpp is incomplete in current
                    gcc relative to gcc 2.95.3
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fnf at specifixinc dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
@ 2007-01-07  1:09 ` pinskia at gcc dot gnu dot org
  2007-01-07  1:21 ` fnf at specifixinc dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-01-07  1:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-01-07 01:09 -------
Confirmed, a regression from 3.2.3.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |rejects-valid
      Known to fail|                            |3.3.3 3.4.0 4.0.0 4.1.0
                   |                            |4.2.0 4.0.4 4.1.2 4.1.1
                   |                            |4.1.0 4.0.3 4.0.2 4.0.1
      Known to work|                            |3.2.3 3.0.4 2.95.3
   Last reconfirmed|0000-00-00 00:00:00         |2007-01-07 01:09:47
               date|                            |
            Summary|Support for -traditional-cpp|[4.0/4.1/4.2/4.3 Regression]
                   |is incomplete in current gcc|Support for -traditional-cpp
                   |relative to gcc 2.95.3      |is incomplete in current gcc
                   |                            |relative to gcc 2.95.3
   Target Milestone|---                         |4.0.4


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


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

* [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
  2007-01-07  1:09 ` [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
@ 2007-01-07  1:21 ` fnf at specifixinc dot com
  2007-02-03 21:23 ` gdr at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: fnf at specifixinc dot com @ 2007-01-07  1:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fnf at specifixinc dot com  2007-01-07 01:21 -------
Created an attachment (id=12867)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12867&action=view)
Patch to fix reported problem


-- 


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


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

* [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
  2007-01-07  1:09 ` [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
  2007-01-07  1:21 ` fnf at specifixinc dot com
@ 2007-02-03 21:23 ` gdr at gcc dot gnu dot org
  2007-02-03 21:24 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: gdr at gcc dot gnu dot org @ 2007-02-03 21:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from gdr at gcc dot gnu dot org  2007-02-03 21:23 -------
won't fix in GCC-4.0.x.  Adjusting milestone.


-- 

gdr at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.4                       |4.1.3


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


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

* [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
                   ` (2 preceding siblings ...)
  2007-02-03 21:23 ` gdr at gcc dot gnu dot org
@ 2007-02-03 21:24 ` pinskia at gcc dot gnu dot org
  2007-02-05  5:49 ` mmitchel at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-02-03 21:24 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.1.3                       |4.1.2


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


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

* [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
                   ` (3 preceding siblings ...)
  2007-02-03 21:24 ` pinskia at gcc dot gnu dot org
@ 2007-02-05  5:49 ` mmitchel at gcc dot gnu dot org
  2007-02-14  9:20 ` mmitchel at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-02-05  5:49 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


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

* [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
                   ` (4 preceding siblings ...)
  2007-02-05  5:49 ` mmitchel at gcc dot gnu dot org
@ 2007-02-14  9:20 ` mmitchel at gcc dot gnu dot org
  2007-12-16 23:19 ` steven at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-02-14  9:20 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.1.2                       |4.1.3


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


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

* [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
                   ` (5 preceding siblings ...)
  2007-02-14  9:20 ` mmitchel at gcc dot gnu dot org
@ 2007-12-16 23:19 ` steven at gcc dot gnu dot org
  2007-12-18  4:09 ` tromey at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: steven at gcc dot gnu dot org @ 2007-12-16 23:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from steven at gcc dot gnu dot org  2007-12-16 23:18 -------
Open regression with no activity since February 14.  Ping?


-- 


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


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

* [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
                   ` (6 preceding siblings ...)
  2007-12-16 23:19 ` steven at gcc dot gnu dot org
@ 2007-12-18  4:09 ` tromey at gcc dot gnu dot org
  2008-01-07 17:30 ` tromey at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-12-18  4:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from tromey at gcc dot gnu dot org  2007-12-18 04:09 -------
I'll review the patch at least.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at gcc dot gnu dot
                   |                            |org
         AssignedTo|unassigned at gcc dot gnu   |tromey at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-01-07 01:09:47         |2007-12-18 04:09:07
               date|                            |


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


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

* [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
                   ` (7 preceding siblings ...)
  2007-12-18  4:09 ` tromey at gcc dot gnu dot org
@ 2008-01-07 17:30 ` tromey at gcc dot gnu dot org
  2008-01-07 17:34 ` [Bug preprocessor/30363] [4.0/4.1/4.2 " tromey at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: tromey at gcc dot gnu dot org @ 2008-01-07 17:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from tromey at gcc dot gnu dot org  2008-01-07 17:24 -------
Subject: Bug 30363

Author: tromey
Date: Mon Jan  7 17:23:40 2008
New Revision: 131379

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131379
Log:
libcpp
2008-01-07  Fred Fish  <fnf@specifix.com>
        PR preprocessor/30363:
        * traditional.c (replace_args_and_push): Add local variable
        cxtquote, calculate the replacement text size assuming a 
        worst case of every input character quoted with backslash,
        and properly handle output quoting of quote characters in
        actual arguments used in function-like macros.
gcc/testsuite
2008-01-07  Fred Fish  <fnf@specifix.com>
        PR preprocessor/30363:
        * gcc.dg/cpp/trad/macroargs.c: Add code to test quoting in
        macro expansions.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/cpp/trad/macroargs.c
    trunk/libcpp/ChangeLog
    trunk/libcpp/traditional.c


-- 


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


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

* [Bug preprocessor/30363] [4.0/4.1/4.2 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
                   ` (8 preceding siblings ...)
  2008-01-07 17:30 ` tromey at gcc dot gnu dot org
@ 2008-01-07 17:34 ` tromey at gcc dot gnu dot org
  2008-07-04 21:48 ` [Bug preprocessor/30363] [4.2 " jsm28 at gcc dot gnu dot org
  2009-03-30 20:21 ` jsm28 at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: tromey at gcc dot gnu dot org @ 2008-01-07 17:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from tromey at gcc dot gnu dot org  2008-01-07 17:25 -------
Slightly modified version of this patch checked in on trunk.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|3.2.3 3.0.4 2.95.3          |3.2.3 3.0.4 2.95.3 4.3.0
            Summary|[4.0/4.1/4.2/4.3 Regression]|[4.0/4.1/4.2 Regression]
                   |Support for -traditional-cpp|Support for -traditional-cpp
                   |is incomplete in current gcc|is incomplete in current gcc
                   |relative to gcc 2.95.3      |relative to gcc 2.95.3


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


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

* [Bug preprocessor/30363] [4.2 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
                   ` (9 preceding siblings ...)
  2008-01-07 17:34 ` [Bug preprocessor/30363] [4.0/4.1/4.2 " tromey at gcc dot gnu dot org
@ 2008-07-04 21:48 ` jsm28 at gcc dot gnu dot org
  2009-03-30 20:21 ` jsm28 at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 21:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jsm28 at gcc dot gnu dot org  2008-07-04 21:48 -------
Closing 4.1 branch.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.1/4.2 Regression] Support|[4.2 Regression] Support for
                   |for -traditional-cpp is     |-traditional-cpp is
                   |incomplete in current gcc   |incomplete in current gcc
                   |relative to gcc 2.95.3      |relative to gcc 2.95.3
   Target Milestone|4.1.3                       |4.2.5


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


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

* [Bug preprocessor/30363] [4.2 Regression] Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3
  2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
                   ` (10 preceding siblings ...)
  2008-07-04 21:48 ` [Bug preprocessor/30363] [4.2 " jsm28 at gcc dot gnu dot org
@ 2009-03-30 20:21 ` jsm28 at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-30 20:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jsm28 at gcc dot gnu dot org  2009-03-30 20:21 -------
Closing 4.2 branch, fixed in 4.3.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to fail|3.3.3 3.4.0 4.0.0 4.1.0     |3.3.3 3.4.0 4.0.0 4.1.0
                   |4.2.0 4.0.4 4.1.2 4.1.1     |4.2.0 4.0.4 4.1.2 4.1.1
                   |4.1.0 4.0.4 4.0.3 4.0.2     |4.1.0 4.0.4 4.0.3 4.0.2
                   |4.0.1                       |4.0.1 4.2.5
         Resolution|                            |FIXED
   Target Milestone|4.2.5                       |4.3.0


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


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

end of thread, other threads:[~2009-03-30 20:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-04  3:24 [Bug preprocessor/30363] New: Support for -traditional-cpp is incomplete in current gcc relative to gcc 2.95.3 fnf at specifixinc dot com
2007-01-07  1:09 ` [Bug preprocessor/30363] [4.0/4.1/4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
2007-01-07  1:21 ` fnf at specifixinc dot com
2007-02-03 21:23 ` gdr at gcc dot gnu dot org
2007-02-03 21:24 ` pinskia at gcc dot gnu dot org
2007-02-05  5:49 ` mmitchel at gcc dot gnu dot org
2007-02-14  9:20 ` mmitchel at gcc dot gnu dot org
2007-12-16 23:19 ` steven at gcc dot gnu dot org
2007-12-18  4:09 ` tromey at gcc dot gnu dot org
2008-01-07 17:30 ` tromey at gcc dot gnu dot org
2008-01-07 17:34 ` [Bug preprocessor/30363] [4.0/4.1/4.2 " tromey at gcc dot gnu dot org
2008-07-04 21:48 ` [Bug preprocessor/30363] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 20:21 ` jsm28 at gcc dot gnu dot org

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