public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
@ 2010-10-31 10:14 ` paolo.carlini at oracle dot com
  2010-11-08 11:03 ` kayhayen at gmx dot de
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2010-10-31 10:14 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2010.10.31 10:14:41
            Summary|Warning for \0 in C++0x raw |[C++0x] Warning for \0 in
                   |strings                     |raw strings
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2010-10-31 10:14:41 UTC ---
Please provide a self-contained reproducer, thanks.


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
  2010-10-31 10:14 ` [Bug c++/45399] [C++0x] Warning for \0 in raw strings paolo.carlini at oracle dot com
@ 2010-11-08 11:03 ` kayhayen at gmx dot de
  2010-11-08 12:19 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: kayhayen at gmx dot de @ 2010-11-08 11:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Kay Hayen <kayhayen at gmx dot de> 2010-11-08 11:03:31 UTC ---
Created attachment 22319
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22319
Warning for \0 in raw strings test case

Well, here it is.

Use like this: g++ -c -std=c++0x raw.c++

Best regards,
Kay Hayen


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
  2010-10-31 10:14 ` [Bug c++/45399] [C++0x] Warning for \0 in raw strings paolo.carlini at oracle dot com
  2010-11-08 11:03 ` kayhayen at gmx dot de
@ 2010-11-08 12:19 ` redi at gcc dot gnu.org
  2010-11-08 12:26 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2010-11-08 12:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |UNCONFIRMED
     Ever Confirmed|1                           |0

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-11-08 12:19:12 UTC ---
The null character is not part of the basic source character set, so it's
implementation-defined how a null in the source file is translated - so
arguably a warning is appropriate.  I tend to agree it's not necessarily useful
for raw strings.

(In reply to comment #0)
> Also please consider it a bug. What else is the purpose of raw strings other
> than to contain binary blobs?

There are lots of uses other than binary data, e.g. writing regular expressions
without needing to escape every backslash.


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2010-11-08 12:19 ` redi at gcc dot gnu.org
@ 2010-11-08 12:26 ` redi at gcc dot gnu.org
  2010-11-08 17:43 ` kayhayen at gmx dot de
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2010-11-08 12:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-11-08 12:26:16 UTC ---
The motivating examples in the original raw strings proposal are for
simplifying regular expressions and HTML markup, there's no mention of binary
blobs.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2053.html


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2010-11-08 12:26 ` redi at gcc dot gnu.org
@ 2010-11-08 17:43 ` kayhayen at gmx dot de
  2010-11-08 18:32 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: kayhayen at gmx dot de @ 2010-11-08 17:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Kay Hayen <kayhayen at gmx dot de> 2010-11-08 17:43:23 UTC ---
(In reply to comment #4)
> The motivating examples in the original raw strings proposal are for
> simplifying regular expressions and HTML markup, there's no mention of binary
> blobs.
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2053.html

I tend to agree that avoiding of backslashes is already something. But raw
strings are definitely also useful to store arbitrary data.

I use them in Nuitka to store the binary blobs from marshaled constants.
Currently I have to have Python code like this to do that:

    def _encodeString( self, value ):
        delimiter = self._pickRawDelimiter( value )

        start = 'R"' + delimiter + "("
        end = ")" + delimiter + '"'

        result = start + value + end

        # Replace \n, \r and \0 in the raw strings. The \0 gives a silly
warning from
        # gcc (bug reported) and \n and \r even lead to wrong strings. Somehow
the
        # parser of the C++ doesn't yet play nice with these.

        def decide( match ):
            if match.group(0) == "\n":
                return end + r' "\n" ' + start
            elif match.group(0) == "\r":
                return end + r' "\r" ' + start
            else:
                return end + r' "\0" ' + start

        result = re.sub( "\n|\r|" + chr(0), decide, result )

As you can see, I somehow believe that "\n" and "\r" are not interpreted
correctly and replace these (should it be necessary, at least at one time it
was?) and then added the same for chr(0) later on.

I consider the necessity to do each of those a bug. In my mind all it should
take would be a delimiter not present in the string. Still I am thankful for
raw strings as those are way easier to get right than a readable Python to
plain C++ string translation.

And the intention of a C++ feature, since when did it ever come to limit its
use? I admit that files with "\0" inside are not the sane thing to write. But
for me C++ is something I generate as a temporary intermediate step. Please
provide a means to disable that warning without disabling everything, or even
stop it for raw strings.

Yours,
Kay

PS: If you are interested in what I do with Nuitka, feel free to visit
http://kayhayen24x7.homelinux.org/blog/nuitka-a-python-compiler/what-is-nuitka/


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2010-11-08 17:43 ` kayhayen at gmx dot de
@ 2010-11-08 18:32 ` redi at gcc dot gnu.org
  2011-05-25  5:39 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2010-11-08 18:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-11-08 18:31:47 UTC ---
(In reply to comment #5)
> As you can see, I somehow believe that "\n" and "\r" are not interpreted
> correctly and replace these (should it be necessary, at least at one time it
> was?) and then added the same for chr(0) later on.

There's no need to replace newlines. There's only a need to replace nuls to
avoid a warning.  Carriage returns in the source code seem to get stripped from
the raw string.

> And the intention of a C++ feature, since when did it ever come to limit its
> use?

Agreed, I was just answering your question "What else is the purpose of raw
strings other than to contain binary blobs?"


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2010-11-08 18:32 ` redi at gcc dot gnu.org
@ 2011-05-25  5:39 ` jason at gcc dot gnu.org
  2011-05-25  7:14 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-25  5:39 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|2010-10-31 10:14:41         |2011.05.25 04:55:09
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-25 04:55:09 UTC ---
Jakub, any objection to dropping this warning from lex_raw_string?


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2011-05-25  5:39 ` jason at gcc dot gnu.org
@ 2011-05-25  7:14 ` jakub at gcc dot gnu.org
  2011-06-15 18:19 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-25  7:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-25 06:31:31 UTC ---
No objection I think.  Alternatively there could be a switch to control this
warning.


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2011-05-25  7:14 ` jakub at gcc dot gnu.org
@ 2011-06-15 18:19 ` jason at gcc dot gnu.org
  2011-06-15 18:41 ` manu at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-15 18:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2011-06-15 18:19 ` jason at gcc dot gnu.org
@ 2011-06-15 18:41 ` manu at gcc dot gnu.org
  2011-06-16 22:15 ` jason at gcc dot gnu.org
  2011-06-17  0:13 ` jason at gcc dot gnu.org
  11 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2011-06-15 18:41 UTC (permalink / raw)
  To: gcc-bugs

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

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

--- Comment #9 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-06-15 18:40:40 UTC ---
(In reply to comment #8)
> No objection I think.  Alternatively there could be a switch to control this
> warning.

Or both. I wish clang published a list of their warning options, so we can keep
compatibility. 

According to this:

https://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?revision=39294&view=markup&sortby=rev&pathrev=63060

They have three different warnings for this but I am not sure if the options
are called -Wnull-in-char, -Wnull-in-string, and -Wnull-in-file.


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2011-06-15 18:41 ` manu at gcc dot gnu.org
@ 2011-06-16 22:15 ` jason at gcc dot gnu.org
  2011-06-17  0:13 ` jason at gcc dot gnu.org
  11 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-16 22:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-16 22:09:16 UTC ---
Author: jason
Date: Thu Jun 16 22:09:12 2011
New Revision: 175121

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175121
Log:
    PR c++/45399
    * lex.c (lex_raw_string): Don't check for embedded NUL.

Added:
    trunk/gcc/testsuite/c-c++-common/raw-string-12.c
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libcpp/ChangeLog
    trunk/libcpp/lex.c


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

* [Bug c++/45399] [C++0x] Warning for \0 in raw strings
       [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2011-06-16 22:15 ` jason at gcc dot gnu.org
@ 2011-06-17  0:13 ` jason at gcc dot gnu.org
  11 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-17  0:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-17 00:12:38 UTC ---
Fixed for 4.7.0.


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

end of thread, other threads:[~2011-06-17  0:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-45399-4@http.gcc.gnu.org/bugzilla/>
2010-10-31 10:14 ` [Bug c++/45399] [C++0x] Warning for \0 in raw strings paolo.carlini at oracle dot com
2010-11-08 11:03 ` kayhayen at gmx dot de
2010-11-08 12:19 ` redi at gcc dot gnu.org
2010-11-08 12:26 ` redi at gcc dot gnu.org
2010-11-08 17:43 ` kayhayen at gmx dot de
2010-11-08 18:32 ` redi at gcc dot gnu.org
2011-05-25  5:39 ` jason at gcc dot gnu.org
2011-05-25  7:14 ` jakub at gcc dot gnu.org
2011-06-15 18:19 ` jason at gcc dot gnu.org
2011-06-15 18:41 ` manu at gcc dot gnu.org
2011-06-16 22:15 ` jason at gcc dot gnu.org
2011-06-17  0:13 ` jason 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).