public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57757] New: CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals
@ 2013-06-29 14:05 harald at gigawatt dot nl
  2013-06-29 14:51 ` [Bug c++/57757] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: harald at gigawatt dot nl @ 2013-06-29 14:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57757
           Summary: CPP extra inserted whitespace needs to be reviewed for
                    C++11 user-defined literals
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: harald at gigawatt dot nl

This invalid code

void operator"" _u(const char *, __SIZE_TYPE__) { }

#define ID(x) x
int main() {
  ID("")ID(_u);
}

is correctly rejected with

$ g++ -std=c++11 -c test.cc
test.cc: In function ‘int main()’:
test.cc:5:12: error: expected ‘;’ before ‘_u’
   ID("")ID(_u);
            ^
test.cc:3:15: note: in definition of macro ‘ID’
 #define ID(x) x
               ^

as the "" and _u are separate tokens. However, with -save-temps, it gets
accepted incorrectly, because in the preprocessor output, "" and _u are joined
as ""_u.

$ g++ -std=c++11 -save-temps -c test.cc
(no output)

The preprocessor needs to insert a space between "" and _u in C++11 mode. For C
mode and C++03 mode, whitespace is not required, and as the documentation
states that GCC does not insert whitespace unless required, the preprocessor
output should only change in C++11 mode.

Modifying the example slightly, it's also possible to get something that
compiles without -save-temps, and gets rejected with it:

#define ID(x) x

void operator ID("")ID(_u)(const char *, __SIZE_TYPE__) { }

int main() {
  ""_u;
}

$ g++ -std=c++11 -c test.cc
$ g++ -std=c++11 -save-temps -c test.cc
test.cc:3:6: error: missing space between ‘""’ and suffix identifier
 void operator ID("")ID(_u)(const char *, __SIZE_TYPE__) { }
      ^
test.cc: In function ‘int main()’:
test.cc:6:3: error: unable to find string literal operator ‘operator"" _u’
   ""_u;
   ^
>From gcc-bugs-return-425422-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jun 29 14:06:37 2013
Return-Path: <gcc-bugs-return-425422-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 12335 invoked by alias); 29 Jun 2013 14:06:36 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 12292 invoked by uid 48); 29 Jun 2013 14:06:33 -0000
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/34547] NULL(): Fortran 2003 changes, accepts invalid, ICE on invalid
Date: Sat, 29 Jun 2013 14:06:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.3.0
X-Bugzilla-Keywords: accepts-invalid, diagnostic, ice-on-invalid-code, rejects-valid
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dominiq at lps dot ens.fr
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-34547-4-x8VQmaS1m4@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-34547-4@http.gcc.gnu.org/bugzilla/>
References: <bug-34547-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-06/txt/msg01801.txt.bz2
Content-length: 622

http://gcc.gnu.org/bugzilla/show_bug.cgi?id4547

--- Comment #8 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> It looks like it was fixed in 4.7.0 with the following error message
>
> Error: NULL intrinsic at (1) in data transfer statement requires MOLD
Confirmed, however compiling the second test in comment #0, namely

 integer, allocatable :: i(:)
 print *, NULL(i)
end

gives an ICE with 4.8.1 and trunk (4.9)

pr34547_1.f90:2:0: internal compiler error: in gfc_conv_expr_descriptor, at
fortran/trans-array.c:6423
  print *, NULL(i)

It compiles with 4.7.3, and gives the reported error with 4.6.4.


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

* [Bug c++/57757] CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals
  2013-06-29 14:05 [Bug c++/57757] New: CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals harald at gigawatt dot nl
@ 2013-06-29 14:51 ` jakub at gcc dot gnu.org
  2013-06-29 15:04 ` harald at gigawatt dot nl
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-06-29 14:51 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That should be fixed by the r200563 changes committed today for the trunk.  Not
sure if a backport of that is planned or not though.


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

* [Bug c++/57757] CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals
  2013-06-29 14:05 [Bug c++/57757] New: CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals harald at gigawatt dot nl
  2013-06-29 14:51 ` [Bug c++/57757] " jakub at gcc dot gnu.org
@ 2013-06-29 15:04 ` harald at gigawatt dot nl
  2013-06-29 15:34 ` harald at gigawatt dot nl
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: harald at gigawatt dot nl @ 2013-06-29 15:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Harald van Dijk <harald at gigawatt dot nl> ---
Thanks for the pointer. That commit looks like it fixes a different issue: that
looks like it's about allowing

void operator""_u(const char *, __SIZE_TYPE__) { }

which was previously rejected. It does not actually fix the issue my testcase
demonstrates, it merely makes it so that my testcase no longer demonstrates my
issue. I'll attempt to come up with a different testcase.


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

* [Bug c++/57757] CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals
  2013-06-29 14:05 [Bug c++/57757] New: CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals harald at gigawatt dot nl
  2013-06-29 14:51 ` [Bug c++/57757] " jakub at gcc dot gnu.org
  2013-06-29 15:04 ` harald at gigawatt dot nl
@ 2013-06-29 15:34 ` harald at gigawatt dot nl
  2013-06-29 17:27 ` harald at gigawatt dot nl
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: harald at gigawatt dot nl @ 2013-06-29 15:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Harald van Dijk <harald at gigawatt dot nl> ---
Updated testcase, tested with :

#define ID(x) x
extern ID("C")void exit(int);
int main() { exit(0); }

This should be accepted, and is, except when -save-temps is used:

$ ~/gcc-run/bin/g++ -std=c++11 -c test.cc
$ ~/gcc-run/bin/g++ -std=c++11 -save-temps -c test.cc
test.cc:2:8: error: expected unqualified-id before ‘STRING_USERDEF’ token
 extern ID("C")void exit(int);
        ^
test.cc: In function ‘int main()’:
test.cc:3:20: error: ‘exit’ was not declared in this scope
 int main() { exit(0); }
                    ^
$ ~/gcc-run/bin/g++ --version
g++ (GCC) 4.9.0 20130629 (experimental)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Using sources from git mirror, commit 801070f5acc11e86fd587b583ebe2ce900ab7a5d,
corresponding to svn rev 200565.
>From gcc-bugs-return-425430-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jun 29 15:36:58 2013
Return-Path: <gcc-bugs-return-425430-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 23232 invoked by alias); 29 Jun 2013 15:36:57 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 23203 invoked by uid 48); 29 Jun 2013 15:36:54 -0000
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/48244] iso-c-binding support missing on NetBSD (with patch)
Date: Sat, 29 Jun 2013 15:36:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.5.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dominiq at lps dot ens.fr
X-Bugzilla-Status: WAITING
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc everconfirmed
Message-ID: <bug-48244-4-P4y7yfb3Nf@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-48244-4@http.gcc.gnu.org/bugzilla/>
References: <bug-48244-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-06/txt/msg01809.txt.bz2
Content-length: 600

http://gcc.gnu.org/bugzilla/show_bug.cgi?idH244

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2013-06-29
                 CC|                            |cato at df dot lth.se
     Ever confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Is there still maintainers/users of NetBSD?


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

* [Bug c++/57757] CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals
  2013-06-29 14:05 [Bug c++/57757] New: CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals harald at gigawatt dot nl
                   ` (2 preceding siblings ...)
  2013-06-29 15:34 ` harald at gigawatt dot nl
@ 2013-06-29 17:27 ` harald at gigawatt dot nl
  2013-07-05 11:40 ` [Bug preprocessor/57757] " jakub at gcc dot gnu.org
  2013-07-10 17:43 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: harald at gigawatt dot nl @ 2013-06-29 17:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Harald van Dijk <harald at gigawatt dot nl> ---
It looks like this is a simple matter of adding an extra case in
libcpp/lex.c:cpp_avoid_paste, returning true for (CPP_STRING, CPP_NAME) when
UDLs are enabled. (I'd attach a working patch instead of a brief one-sentence
description, but won't because I unfortunately expect copyright assignment
would be a problem.)


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

* [Bug preprocessor/57757] CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals
  2013-06-29 14:05 [Bug c++/57757] New: CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals harald at gigawatt dot nl
                   ` (3 preceding siblings ...)
  2013-06-29 17:27 ` harald at gigawatt dot nl
@ 2013-07-05 11:40 ` jakub at gcc dot gnu.org
  2013-07-10 17:43 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-07-05 11:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-07-05
          Component|c++                         |preprocessor
     Ever confirmed|0                           |1


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

* [Bug preprocessor/57757] CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals
  2013-06-29 14:05 [Bug c++/57757] New: CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals harald at gigawatt dot nl
                   ` (4 preceding siblings ...)
  2013-07-05 11:40 ` [Bug preprocessor/57757] " jakub at gcc dot gnu.org
@ 2013-07-10 17:43 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-07-10 17:43 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Wed Jul 10 16:40:49 2013
New Revision: 200875

URL: http://gcc.gnu.org/viewcvs?rev=200875&root=gcc&view=rev
Log:
    PR preprocessor/57757
    * lex.c (cpp_avoid_paste): Avoid pasting CPP_{,W,UTF8}STRING
    or CPP_STRING{16,32} with CPP_NAME or SPELL_LITERAL token that
    starts if a-zA-Z_.

    * g++.dg/cpp/paste1.C: New test.
    * g++.dg/cpp/paste2.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp/paste1.C
    trunk/gcc/testsuite/g++.dg/cpp/paste2.C
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libcpp/ChangeLog
    trunk/libcpp/lex.c

Fixed for 4.9+.


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

end of thread, other threads:[~2013-07-10 17:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-29 14:05 [Bug c++/57757] New: CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals harald at gigawatt dot nl
2013-06-29 14:51 ` [Bug c++/57757] " jakub at gcc dot gnu.org
2013-06-29 15:04 ` harald at gigawatt dot nl
2013-06-29 15:34 ` harald at gigawatt dot nl
2013-06-29 17:27 ` harald at gigawatt dot nl
2013-07-05 11:40 ` [Bug preprocessor/57757] " jakub at gcc dot gnu.org
2013-07-10 17:43 ` jakub at gcc dot gnu.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).