evilsong / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

'PR' style format specifiers apparently conflict with C++11 user defined literals; build fails for C++11 #429

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add --std=c++11 (or --std=c++0x) to CXXFLAGS when building tcmalloc
2.
3.

What is the expected output? What do you see instead?
The expected output is an OK build, but instead errors like this show up:

With clang:
src/malloc_extension.cc:247:16: error: invalid suffix on literal; C++11 
requires a space between
      literal and identifier [-Wreserved-user-defined-literal]
           "%6"PRIu64": %8"PRIu64" [%6"PRIu64": %8"PRIu64"] @",

With gcc:
src/malloc_extension.cc: In function 'void 
{anonymous}::PrintCountAndSize(MallocExtensionWriter*, uintptr_t, uintptr_t)':
src/malloc_extension.cc:247:61: error: unable to find string literal operator 
'operator"" PRIu64'

So both compilers agree that something is not quite right here.

What version of the product are you using? On what operating system?
I'm using SVN r149 on Ubuntu 12.04 x86_64.

Please provide any additional information below.
I've tried this both with gcc-snapshot (currently 4.8.0 20120314) and with 
clang (llvm r156554, clang r156552, built from source).

It seems that clang has the more informative error here, and its suggestion 
about adding a space between the end of the previous string and the start of 
portable format specifier fixes the problem.

I've attached a patch that makes this change in case it is useful.

Original issue reported on code.google.com by andrew.c.morrow@gmail.com on 10 May 2012 at 8:11

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for the patch Andrew. I will be doing another round of patch work 
shortly.

Original comment by chapp...@gmail.com on 15 May 2012 at 1:27

GoogleCodeExporter commented 9 years ago

Original comment by chapp...@gmail.com on 15 May 2012 at 1:33

GoogleCodeExporter commented 9 years ago
Any news on this?

Original comment by andrew.c.morrow@gmail.com on 11 Jul 2012 at 6:16

GoogleCodeExporter commented 9 years ago

Original comment by chapp...@gmail.com on 4 Nov 2012 at 5:29