3,901 karma · joined Oct 15, 2012 (14y ago) · 1,547 submissions
comment 9y ago · link · parent
Does the POSIX documentation have anything like it? I don't recall so remind me if it does.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...
comment 9y ago · link · parent
This is so patently wrong.
Firstly, the first example I thought of (CreateFile) clearly stated that you could get ERROR_FILE_NOT_FOUND, ERROR_ALREADY_EXISTS, ERROR_FILE_EXISTS, ERROR_PIPE_BUSY, ERROR_SHARING_VIOLATION, ERROR_ACCESS_DENIED.
Secondly, drivers can sometimes return error codes that the OS might not expect to be necessary, and the OS can't just coerce the error codes into something else; it'd lose information. [1] For example, if you CreateFile, a driver that mandatorily logs data might decide to return an error saying it's low on disk space even though the file already exists, which you wouldn't expect. If your code isn't specially written to handle it, you should treat it as the general failure condition it is.
Heck, you can even think of Windows as returning "TRUE" (for no error) or "FALSE" (for error), and GetLastError as just providing details you can ignore. Simply the fact that you know the possibilities are TRUE and FALSE doesn't satisfy you though, does it? So isn't the problem that Linux is just suppressing information it could actually pass through?
If anything, Windows is doing this right and Linux is doing it right by being restrictive on the returned information... but in any cases, at best you can suggest they're both "different" and maybe on a good day people would entertain the possibility. Certainly returning MORE information than you need is not something you can call out as a flaw...
[1] e.g. see http://stackoverflow.com/a/19249991
comment 9y ago · link · parent
> I'm not. I'm assuming these decisions are made because people in physics/ME/chemistry are not programmers and don't know about the latest and greatest our field has to offer. It's our fault for not advertising our successes to these people.
And how many FORTRAN HPC programmers do you know?
comment 9y ago · link · parent
comment 9y ago · link · parent
If I were CEO I would be surprised if a manager at my company didn't even know who was working under him. If I were a math professor I would be surprised if the TA I just hired didn't know two quarters is the same as one half. If I were the president of the United States I would be surprised if my vice president thought he was president. etc.
Why? Because all of these cases involve someone's lack of knowledge almost certainly resulting in someone else getting completely screwed over. It doesn't matter what the ranks of the people involved are, it just matters if there are serious potential damages at stake.
comment 9y ago · link · parent
I just said you should be surprised if you get an antibiotic prescribed for a viral infection. Yes, you really should be surprised. That doesn't mean you have to declare the doctor incompetent. It just means you should be surprised and act accordingly. Which means you have to confirm that it's correct, to make sure the doctor is not totally screwing up. Because chances are decent the antibiotics are useless. The chances don't need to be 100% for you to be surprised and to show it too.
comment 9y ago · link · parent
comment 9y ago · link · parent
I didn't realize this can trigger the bug though, so if it does, I should clarify I didn't mean to include it in my comment. I was only referring to cases where there is no intervening operation between construction and destruction.
comment 9y ago · link · parent
Backwards-compatibility notwithstanding, it would not be totally illogical for C++ to allow optimizing out construct-destruct chains even in the presence of side effects, in a similar manner to the existing copy elision behavior. After all, the object is unused, and the destructor should be merely undoing whatever the constructor did, so afterward it should be as if the object was never constructed.
If you rely on the side effects of normal construction, that's not so different from relying on the side effects of copy construction, which you can't already do. Hence you shouldn't do the first either.
So yes, it's a bug, and needs to be fixed, but regardless of that, you shouldn't write code like this in the first place.
EDIT: See comment below, apparently the bug comes up in more cases than those I referred to here.