Bug 13626 - gcc 4.7 doesn't compile sdt.h with -std=c++0x
Summary: gcc 4.7 doesn't compile sdt.h with -std=c++0x
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: runtime (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-26 22:26 UTC by Mark Wielaard
Modified: 2012-01-26 23:11 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2012-01-26 22:26:45 UTC
With gcc 4.7 prerelease, gcc (GCC) 4.7.0 20120123 (Red Hat 4.7.0-0.9) as found in Fedora Rawhide, sdt.h doesn't compile with g++ -std=c++0x

FAIL: compiling sdt.c c++0x  uprobe
FAIL: compiling sdt.c c++0x -pedantic uprobe
FAIL: compiling sdt.c gnu++0x  uprobe
FAIL: compiling sdt.c gnu++0x -pedantic uprobe
FAIL: sdt_misc compiling types V3_uprobe c++0x 
FAIL: sdt_misc compiling types V3_uprobe c++0x -pedantic
FAIL: sdt_misc compiling types V3_uprobe gnu++0x 
FAIL: sdt_misc compiling types V3_uprobe gnu++0x -pedantic
FAIL: compiling sdt_va_args.c c++0x

Other -std settings work fine.

Error look like:

Executing on host: g++ /home/mark/src/systemtap/testsuite/systemtap.base/sdt.c  -g -isystem/home/mark/src/systemtap/testsuite -isystem/usr/local/install/systemtap/include -Wall -Wextra -Werror  -std=c++0x -x c++   -lm   -o sdt.c.exe.7    (timeout = 300)
spawn -ignore SIGHUP g++ /home/mark/src/systemtap/testsuite/systemtap.base/sdt.c -g -isystem/home/mark/src/systemtap/testsuite -isystem/usr/local/install/systemtap/include -Wall -Wextra -Werror -std=c++0x -x c++ -lm -o sdt.c.exe.7
/home/mark/src/systemtap/testsuite/systemtap.base/sdt.c: In function 'void call0()':
/home/mark/src/systemtap/testsuite/systemtap.base/sdt.c:5:3: error: unable to find string literal operator 'operator"" _SDT_S'
/home/mark/src/systemtap/testsuite/systemtap.base/sdt.c:5:1: error: unable to find string literal operator 'operator"" _SDT_S'
/home/mark/src/systemtap/testsuite/systemtap.base/sdt.c: In function 'void call1(int)':
/home/mark/src/systemtap/testsuite/systemtap.base/sdt.c:10:3: error: unable to find string literal operator 'operator"" _SDT_S'
/home/mark/src/systemtap/testsuite/systemtap.base/sdt.c:10:1: error: unable to find string literal operator 'operator"" _SDT_S'
/home/mark/src/systemtap/testsuite/systemtap.base/sdt.c: At global scope:
/home/mark/src/systemtap/testsuite/systemtap.base/sdt.c:8:13: error: unused parameter 'a' [-Werror=unused-parameter]
[...]

I think this is a g++ bug since sdt.h contains:
# define _SDT_S(x)                      #x

Or is there a reason that doesn't work with c++0x?
Comment 1 Mark Wielaard 2012-01-26 22:41:21 UTC
This is a bug in sdt.h. gcc 4.7 supports user defined literals (UDF):
https://en.wikipedia.org/wiki/C%2B%2B11#User-defined_literals

In std=c++0x mode one now needs to add whitespace.
See http://gcc.gnu.org/gcc-4.7/porting_to.html
Comment 2 Mark Wielaard 2012-01-26 23:11:22 UTC
commit 99712e8716e19293fe1f6dd84854d350e57945e0
Author: Mark Wielaard <mjw@redhat.com>
Date:   Thu Jan 26 23:58:38 2012 +0100

    PR13626 Add extra whitespace in sdt.h to deal with C11/C++11 UDF.
    
    gcc 4.7 supports C11/C++11 user defined literals (UDF):
    https://en.wikipedia.org/wiki/C%2B%2B11#User-defined_literals
    In std=c++0x mode one now needs to add whitespace between string literals.
    See http://gcc.gnu.org/gcc-4.7/porting_to.html