Linked by martini on Tue 23rd Oct 2012 22:02 UTC
X11, Window Managers Wayland 1.0 was officialy released on October 22. Wayland is a protocol for a compositor to talk to its clients as well as a C library implementation of that protocol. The compositor can be a standalone display server running on Linux kernel modesetting and evdev input devices, an X application, or a wayland client itself. The clients can be traditional applications, X servers (rootless or fullscreen) or other display servers.
Permalink for comment 540339
To read all comments associated with this story, please click here.
RE[7]: Comment by stabbyjones
by f0dder on Sun 28th Oct 2012 16:09 UTC in reply to "RE[6]: Comment by stabbyjones"
f0dder
Member since:
2009-08-05

char a[]="This is a very long non-const test string..."; // global variable might initially be loaded into shared memory pages.
void f() {
a[0]++; // segfault?
}
TC++PL, 5.2.2: "The type of a string literal is 'array of the appropriate number of const characters'" and "A string literal can be assigned to a char*. This is allowed because in previous definitions of C and C++, the type of a string literal was char*. Allowing the assignment of a string literal to a char* ensures that millions of lines of C and C++ remain valid. It is, however, an error to try to modify a string literal through such a pointer."

So, undefined behavior in C++, segfault if your compiler puts string data in readonly memory (true for Intel's C++ compiler and GCC, but not MSVC).

EDIT: need more coffee - your code is OK since it copies the the string literal into the non-const 'a' char array and assigns a pointer to that, rather than directly to the string literal.

Edited 2012-10-28 16:16 UTC

Reply Parent Score: 2