« first day (658 days earlier)      last day (4291 days later) » 

11:00 AM
@nil The Witcher 2 looks a thousand times better.
Heck, the Witcher 1 looked better.
 
user457812
I personally found both Witchers rather ugly
 
My "sucky graphics" has nothing to do with GPU vendor or driver problems.
The texture quality was below par.
There were no fancy effects used to warrant the relatively bad performance.
 
user457812
I don't think I saw any poor performance in Rage.
 
My 4870 that could pull Crysis 2 on High failed to run Rage. That is Rage's problem, cause Crysis 2 is more advanced in the graphics department.
But hey. Who am I.
 
Xeo
13
Q: Will std::string always be null-terminated in C++11?

links77In a 2008 post on his site, Herb Sutter states the following: There is an active proposal to tighten this up further in C++0x and require null-termination and possibly ban copy-on-write implementations, for concurrency-related reasons. Here’s the paper: http://www.open-std.org/jtc1/sc22/wg21/...

I really think this question may need some clarification
If the std::string keeps the storage, but only writes the null terminator when c_str() or data() is invoked...
 
user457812
11:34 AM
@rubenvb Speaking of Crysis 2, that game was surprisingly good.
 
user457812
Like actually really, really good.
 
11:46 AM
lol @rubenvb
too bad that clang guys don't wanna implement the warning
they seem to think it doesn't pay off
 
@nil True, although the gameplay was a bit... boring. Crysis 1 and Warhead were better.
And they messed up the story big time.
 
@Xeo It would have to do some inefficient thing for operator[] also. very unlikely.
 
Or I missed some crucial element.
 
Xeo
@Cheersandhth.-Alf Why would it?
 
user457812
Crysis 1 was a lot better for the sandbox stuff, but overall, I thought Crysis 2 was really well done.
 
11:51 AM
@Xeo because it must return reference to same elements (address must be equal for all i in 0....n), and appear zero terminated to the client code. in c++11. in c++03 it's only for the const version of [].
 
@JohannesSchaub-litb hehe. There's always a tradeoff.
 
user457812
And yeah, the story became almost parody-like. I mean, really, you're fighting squids.
 
I mean, what happened to the shielded island in Crysis?
They nuked it, it got bigger, and ... nothing?
 
Xeo
@Cheersandhth.-Alf must it appear null terminated?
 
@Xeo c_str() is required to produce a pointer to zero-terminated string, yes.
 
Xeo
11:53 AM
@Cheersandhth.-Alf I know that one, but there's no such requirement for []
 
[] is required to produce same pointer(s) as c_str()
 
Xeo
sure, it can have the same pointer
but the storage mustn't necessarily contain \0
 
21.4.5/2: Returns: *(begin() + pos) if pos < size(). Otherwise, returns a reference to an object of type charT with value charT(), where modifying the object leads to undefined behavior.
Note the otherwise.
 
@Xeo c_str() is required to produce a pointer to zero-terminated string, yes.
 
Xeo
@Cheersandhth.-Alf Yes
 
11:54 AM
c_str() is required to be O(1), so (re)allocation is out of the question.
 
Xeo
lemme explain in a bit
currently playing a game of mahjong
 
lol
 
i think you're maybe thinking that non-const operator[] can modify the buffer contents.
When you have fixed the header, then replace the #define with a C++ constant definition, replace the use of raw char arrays with std::string, and sprikle a generous helping of const all over the place. — Cheers and hth. - Alf 2 mins ago
^ How do other people get links to their comments, for the purpose of one-boxing a quote?
 
@Cheersandhth.-Alf the link the "2 mins ago" points to (just right-click and copy link location)
then just paste it in here.
 
ah, thanks!
just FYI, I did it "the hard way" by going to my own "activity" and copying the link there.
 
12:07 PM
hehe. I always mistake the profile name link with the edited time link. They should just make an extra button/link named "link to this comment" or "permalink".
 
12:40 PM
WTF, the QuakeCon 2012 keynote is three and a half hours long???
2
 
12:56 PM
@FredOverflow yes I felt asleep while watching it
much talk about VR and how things will eventually evolve
But overall I still liked it.
 
Xeo
Alright, now I have time
@Cheersandhth.-Alf So, what I meant was this: The std::stringallocates enough space for the string + null terminator, but only copies the string, leaving the space for the null terminator empty. On a call to c_str() (or data()), the null terminator gets written.
This was, the pointers will be the same for all elements in [0, size()] but &str[0] still wouldn't guarantee a null-terminated string
 
I'm kinda offended that this takes a fucking hour: eu.battle.net/sc2/en/blog/5539446/…
guess this is what I get for being too greedy to buy an ssd
 
streaming client?
 
but I really wonder why it takes a fucking hour??
 
is it something to work like diablo 3 or what?
 
1:10 PM
I have no idea.
I bet on the mac it takes like 1 minute or something
 
> Your post reminds me of a period in my life when I spent waaaay too much time playing Minesweeper.
dafuq?
who the heck can play minesweeper for hours on end?
 
I dont
 
I used to
 
Xeo
Hm... either I'm misunderstanding something, or this part of the standard is quite muddy.
 
I go to the gym
 
Xeo
1:11 PM
on c_str() and data():
> Returns: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
 
I stopped when I completed an advanced game in 99s
I decided that was enough
 
Xeo
Specifically, [0,size()] implies that this includes the place for the null terminator
On operator[]:
> Returns: *(begin() + pos) if pos < size(), otherwise a reference to an object of type T with value charT(); the referenced value shall not be modified.
the part after the comma implies (to me atleast), that this "object of type T" may not reside within the sequence.
 
Except it'd be a silly implementation.
If it keeps space for null, it might as well keep it there.
 
Xeo
sure, but it is possible.
atleast that's how I read it
Which means &str[0] is not guaranteed to provide a null-terminated string.
 
@Xeo it's possible that you have uncovered a defect in the standard. the null-termination is only specified for direct use of operator[], not for c_str().
 
Xeo
1:16 PM
@Cheersandhth.-Alf And only for the use of operator[](size()) it seems
 
yes
i think we can be sure that the intent is to guarantee null-termination
 
C strings are stupid.
 
but i suggest posting the question to [comp.std.c++]
 
There's also the O(1) requirement for c_str
That rules out allocation, and modification is out of the question, as the function is const. So the null terminator has to be there at all times.
 
@rubenvb Unless the internal array is marked volatile
which there's no rule agains
 
Xeo
1:20 PM
@rubenvb no, modification is still possible through indirection
 
@Xeo or that
 
OK, I guess, but not in constant time, right?
 
Xeo
it is
 
@rubenvb If the only modification you need to do is to write a single null byte, that sounds constant-time to me
 
Xeo
char const* c_str() const{ str[size()] = '\0'; return str; }
 
1:21 PM
pointless, but possible
 
OK, but then it's there in all cases except when calling data()
 
Which version of the spec are we reading? IIRC, there was no explicit requirement for the internal buffer being null-terminated in C++03, but C++11 made it explicit
@rubenvb yup. So pointless, but possible ;)
 
Xeo
@rubenvb data() and c_str() have the same specifications
@jalf C++11
And there doesn't seem to be any wording that forces null-termination
Of course it's entirely possible I'm just overlooking it
 
eachWithIndex(list,
    (value, index) -> {
        String output = String.format("%d -> %s", index, value);
        System.out.println(output);
    }
);
Whoa, implicitly typed lambda parameters? Java sure has gone a long way :)
 
So the internal buffer can be non-null-terminated until some function is called that would expose that, and then it will be null-terminated. What's the problem?
 
Xeo
1:24 PM
@rubenvb Not even that is guaranteed
But imagine std::string s = "..."; c_func(&s[0]); // no null-termination guarantee
 
@Xeo aha.
evil, but ok.
 
Xeo
And surely not intended
And even calling c_str()/data() doesn't seem to guarantee that you get a null-terminated string
 
@Xeo yes it does.
 
Xeo
Where?
 
oh wait.
I'm imagining things :)
 
Xeo
1:28 PM
To summarize, c_str()/data() guarantee to always point at the same storage as &operator[](i) for i in [0,size()], but the value referenced by operator[](size()) is not required to be in the sequence... wait.
Now I'm confuzzled
Atleast I can say with confidence that this part of the standard is muddy. :(
 
@Xeo 21.4.1/5
claims contiguous storage
 
Xeo
sure thing
reference operator[](size_type pos){
  if(pos == size())
    return default_char_that_is_null;
  return buf[pos];
}
^ seems to satisfy the requirements for operator[]
 
Now, should I replace my server Gentoo installation with fresh Arch, or not.
 
Xeo
but now the requirements for c_str()/data() don't hold anymore, since c_str() + size() != &operator[](size())
 
1:34 PM
@Xeo it does, the "otherwise" takes care of that doesn't it?
 
Xeo
@rubenvb see the operator[] implementation above, the default_char_that_is_null could reside anywhere outside the sequence
 
!!! Error: Couldn't source /usr/share/eselect/libs/default.eselect
Call stack:
* do_action (core.bash:81)
* main (eselect:197)
exiting
/usr/bin/supervisord: Execution of 'eselect python show --python2' failed
Sigh.
 
Xeo
so it is muddy, but with a bit of back and forth, it seems to guarantee null-termination for all cases...
 
Also funny: /dev/null: Permission denied
udev's broken, eselect's broken.
What a mess.
SCP doesn't work, either.
 
I'm confuzzled.
 
1:38 PM
Aug 04 15:28:24 [sshd] error: open /dev/tty failed - could not set controlling tty: Permission denied
 
@Xeo yeah
although it looks like you could do some remarkably evil things and still stay within the spec
If I call str[str.size()], I could theoretically get a reference to a null byte outside the array. But if I call str.c_str() + str.size(), I'm required to get a null byte at the end of the array. In other words, the behavior of operator[] could theoretically vary depending on context, and return different null byte references
 
Also SCP is so slow.
 
I'm tempted to take this as a challenge. Write the most fucked-up std::string implementation possible, without violating the spec
 
Xeo
@jalf I really don't know how you would accomplish that, though :P
Oh, maybe set a context bit in c_str()? :D
 
@jalf Hell++.
 
Xeo
1:43 PM
@jalf Btw, the last byte in the array is not required to be null in that case :P
 
@Xeo Easy: when you call c_str(), we make sure that the buffer is null-terminated. But when you call str[size()] explicitly, we're free to return a reference to another null byte.
So just keep a static \0 lying around somewhere to trip people up
no, keep a couple, and pick a random one
@Xeo It is required during a c_str() call
 
Xeo
ah, right
seriously, they need to clean that up
 
You know, you could just replace the last character with null, and probably still not violate the formal requirements.
 
@Xeo yeah, that would be wonderfully evil
 
Or return a completely different string.
Boy nobody would expect that
 
Xeo
1:46 PM
operator+ guarantees left-to-right evaluation, right?
 
@CatPlusPlus nah, c_str() is defined in terms of operator[], which in turn is defined in terms of begin(), which has to return referecnes to the string itself
except for the border case of the past-the-end byte
 
@jalf which is exactly what matters in a C string context.
 
@rubenvb yeah, but I mean, you couldn't return a completely different string
 
Let's just get rid of all null-terminated string C APIs.
 
@CatPlusPlus let's burn all of POSIX.
then Linux'd be even more crappily documented!
 
1:48 PM
And non-kernel WinAPI.
 
Wait. What?
 
Kernel-level APIs use UNICODE_STRING, which is a struct of buffer + size.
I.e. the way strings should be done.
 
lol. You'd get rid of the BSD and Linux kernels though.
 
Wow. If you wanted, you could write a truly evil `std::string` implementation. The standard actually allows for some horrific trickery there
 
Leave no room for competition
 
1:51 PM
I could totally pay for a completely new platform, free of compatibility crap.
To start from scratch.
 
The problem is that as soon as it catches on, it starts getting bogged down by compatiiblity crap
 
@CatPlusPlus I wish you luck. What specification are you going to follow for CatOS?
 
Stupid people always make everything difficult.
@rubenvb Which part of "completely new" you didn't catch?
 
@CatPlusPlus So you're writing a spec first?
 
I'm not doing anything, I have a server to rescue.
 
1:53 PM
hmm, let's see. My string class would have to get overwrite the terminating null by some garbage value any time the string is modified. Then on calls to c_str, we have to set it back to null, unfortunately
 
I'm dreaming of better world.
 
no, wait, that doesn't work
 
Transferring files through SCP is slowtastic.
 
@CatPlusPlus I've never had problems with it
 
It caps at about 200kB/s.
 
1:56 PM
well, unless you're using the cygwin implementation
 
While via HTTP from the same server goes full speed.
 
their ssh stinks performance-wise
 
PuTTy.
 
Linux VM ftw.
 
Woah, I have this server for almost 2 years now.
 
2:00 PM
I wonder how much code you'd break by writing such an evil string implementation
 
A lot.
 
If it follows the spec?
Only code that does &somestring[0] and passes that to a C function I guess.
 
I'm a douchebag
 
People don't read the standard.
 
@rubenvb or code which does something like &[s[s.size()]-1 and expects the result to point to the last character in the string
 
2:09 PM
@jalf that's just ridiculous.
but entirely possible.
 
@rubenvb why?
 
@jalf Just do s[s.size()-1]. That will surely work.
 
or code which does something like &str[n] - &str[0], expecting to get a reasonable distance, where, at runtime, n turns out to sometimes equal str.size()
@rubenvb Sure, there are plenty of easy ways to make the code correct
I'm just saying I can imagine a lot of code breaking if you write such a legally evil string class :)
 
That's why I said that the code was ridiculous ;-)
 
Xeo
2:26 PM
@jalf We still don't know for sure if it's legal, do we?
 
@Xeo I see no reason why it wouldn't be
 
Xeo
Maybe we should ask it on SO
 
instant upboats. Cause you said "Standard" and all.
 
I'm pretty sure it's ok
 
Xeo
"Is a std::string implementation conformant where 's.c_str() + s.size()' is not necessarily the same as '&s[s.size()]'?"
hm, that actually sounds like a good question.
 
2:29 PM
I think the spec is fairly explicit about it, if you read it carefully
but feel free to ask it :)
it says that [size()] returns a reference to some CharT(), but doesn't say which (doesn't have to be the one at the end of the buffer)
 
Xeo
aye, but in return, c_str() + size() is required to point at the end of the buffer
specified in terms of operator[](i) for i in [0,size()]
 
and c_str() returns a pointer where each element is the same as you'd get for operator[]. So for the string itself, the results are the same, and for the last element, it is, since it's defined in terms of operator[], required to be a pointer to some null byte. And since we're talking about raw pointers, it can only point to the one located immediately after the buffer
 
Xeo
which kinda contradicts itself
 
@Xeo No, it just says that operator[] is less constrained than data()
operator[] can, in theory, give you a reference to any null byte, including, but not limited to, the one at the end of the buffer
 
Xeo
I understand that
but still xD
 
2:32 PM
so when used in a c_str() context, it just has to return that specific null byte
but in other contexts, there's no strict requirement that it has to return the same null
but in both cases, its behavior is valid
 
Xeo
> object of type T
What is T, btw?
 
where?
 
Xeo
operator[] specification
> otherwise a reference to an object of type T with value charT(); the referenced value shall not be modified.
type T with value charT()
seems like an editorial issue
 
heh, yeah, you're right
sweet, you found an error in the standard. :)
so, if we read this literally, does that mean that operator[] could return any unconstrained type T? ;)
the only requirement is that charT() is one of the valid values T can take
 
It's already fixed in n3337
 
2:39 PM
@rubenvb aww, damn
 
Returns: *(begin() + pos) if pos < size(). Otherwise, returns a reference to an object of type charT with value charT(), where modifying the object leads to undefined behavior.
 
Xeo
Maybe I should get a copy of the newest draft
 
or get the Robot's version
 
Xeo
0
Q: Smallest C++ Program that will complie

user1576209What is the smallest C++ program that will compile without any error. Functionality is not important.

Should I answer "` `, this will compile, but not link. :)"?
 
lol
 
Xeo
2:47 PM
What was the flag to only compile, not link again?
 
@Xeo -c
 
3:04 PM
GCC 4.8 has Win64 SEH (ie native exception handling).
Just thought you'd like to know.
 
Xeo
3:18 PM
reference operator[](size_type pos){
  static contexpr charT default = charT();
  if(pos == size() && !evil_context) // assume 'volatile bool evil_context;'
    return default;
  return buf[pos];
}

struct evil_context_guard{
  volatile bool& ctx;
  evil_context_guard(volatile bool& b)
    : ctx(b) {}
  ~evil_context_guard(){ b = false; }
};

const charT* c_str() const noexcept{
  evil_context_guard g(evil_context = true);
  // now, during the call to 'c_str()', the requirement above holds
  // 'p + i == &operator[](i) for each i in [0,size()]'
@jalf ^ something like that?
 
Hey guys, quick question. Can I use gcc's mudflap on Windows? How do I install it? I'm using MinGW.
 
yeah. Although I don't think you need the explicit "evil-context" at all. operator[] can always return default for the size() case
 
Xeo
@jalf huh?
I thought we concluded that that was not allowed
Since c_str() + size() != &operator[](size()) then
 
Hi all
 
@Xeo c_str() is defined in terms of the specification of operator[], but it doesn't actually call that operator, so the implementation of the operator is irrelevant
The specification of the operator says that it returns some null byte, and c_str imposes the additional requirement that this null byte has to be at the end of the buffer. But when operator[] is called explicitly, there's never any reason why it'd have to return the end-of-buffer nullbyte
at least that's how I'm reading it. The key is to separate the spec and implementation of operator[]. The standard only refers to the spec when it defines c_str, I believe
 
Xeo
3:28 PM
But how could p + size() == &operator[](size()) ever hold if operator[] never returns buf[pos]?
 
@Pieter I'm not sure. It's bot built by default when building MinGW GCC.
 
@rubenvb I got the binary package. When I compile with -fmudflap, it says "mf-runtime.h: no such file or directory".
 
@Pieter that's because libmudflap wasn't built with GCC.
I'm not sure it's possible currently. If you want, I can check it out one of these days.
 
@rubenvb Maybe mudflap isn't my best strategy then. I'm trying to hunt down a possible stack corruption issue (which I've never done before) and I'm trying out various tools that work with MinGW GCC on Windows.
 
@Xeo hmm, sec
 
3:34 PM
@Pieter If you're daring, you can run WINE on Linux and use your usual Linux tools.
 
@Xeo Through the as-if rule, I'd say
 
Xeo
hm
I'll still go with the evil_context, just to be "safe"
 
it doesn't matter that operator[] never actually returns the null-byte at the end of the buffer, as long as the string class acts as if it happened.
 
Xeo
feel free to provide that in your answer ;)
 
which means that we jsut have to get the end-of-buffer null if we go through c_str/data
did you post the question?
 
Xeo
3:36 PM
soon
0
Q: Is a std::string implementation conformant where 's.c_str() + s.size()' is not necessarily the same as '&s[s.size()]'?

Xeo§21.4.5 [string.access] const_reference operator[](size_type pos) const; reference operator[](size_type pos); Returns: *(begin() + pos) if pos < size(). Otherwise, returns a reference to an object of type charT with value charT(), where modifying the object leads to undefined behavior. ...

 
@jalf wouldn't concurrency mess with all that? Or would that mess up anyways?
 
@rubenvb the latter, I'd think
 
ok.
 
Xeo
@jalf You can always just make it null in the ctor / assignment op / whathaveyou
and don't trouble yourself
since null-termination is guaranteed
 
@rubenvb That might be a bit of a hassle, but I'll consider it if I don't find anything else. Are there any popular memory/stack corruption detection tools for C++ on Windows that work with MinGW?
 
3:46 PM
@Pieter not that I know. I'm very basic when it comes to debugging. Much more than really basic gdb is not something I can do or use.
 
@rubenvb Alright, I'll keep looking then. Thanks for your advice!
 
@Pieter You're welcome. Sorry I couldn't help much!
 

« first day (658 days earlier)      last day (4291 days later) »