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

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