Closed Bug 865396 Opened 12 years ago Closed 12 years ago

jsd_xpc.cpp:47:61: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix], for "+++++ "name

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla23

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Build warnings for jsd_xpc.cpp in GCC 4.8: /mozilla/js/jsd/jsd_xpc.cpp:47:61: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] # define DEBUG_CREATE(name, count) {count++; DEBUG_COUNT ("+++++ "name,count)} ^ /mozilla/js/jsd/jsd_xpc.cpp:48:62: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] # define DEBUG_DESTROY(name, count) {count--; DEBUG_COUNT ("----- "name,count)} MXR link: http://mxr.mozilla.org/mozilla-central/source/js/jsd/jsd_xpc.cpp#47 The issue is with "+++++ "name and "----- "name tl;dr, we just need to insert a space before "name" there. LONGER EXPLANATION: So, this code is trying to do string concatenation (where 'name' is a macro-parameter for a string literal). BUT in C++ 11, the code "+++ "name could be interpreted differently, because C++11 has special syntax for characters immediately following a string literal. They're interpreted as being a user-defined literal suffix, sort of like the suffixes after numeric literals in 7.0f and 1000u. More information here: http://en.wikipedia.org/wiki/C%2B%2B11#User-defined_literals and see in particular this example from that wikipedia page, demonstrating the syntax: > OutputType some_variable = "1234"_ssuffix; // Uses the 'const char *' overload. SO ANYWAY: If we insert a space between the two string literals, the result is unchanged and it becomes unambiguous even in light of the new C++11 syntax. Patch coming up to do that.
Assignee: general → dholbert
Status: NEW → ASSIGNED
Attachment #741464 - Flags: review?(jwalden+bmo)
Attachment #741464 - Attachment description: fix → fix (insert space before 'name')
(Note that technically, only suffixes that start with an underscore can have special meaning after a string literal in C++11. But non-underscore-starting suffixes are still reserved for use in *future* specs, according to this reddit comment: http://www.reddit.com/r/cpp/comments/mol07/example_of_c11_compiletime_binary_number_literal/c32m9iq So that means the 'name' suffix in this bug's flagged lines could feasibly obtain some unwanted special meaning in a future C++ draft.)
Attachment #741464 - Flags: review?(jwalden+bmo) → review+
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: