standards

Does the C preprocessor remove instances of “&*”?

空扰寡人 提交于 2019-12-03 14:42:47
问题 I was playing around with gcc and tried the following bit of code: int A = 42; int *B = &A; int *C = &*B; And C == &A , as expected. But when I try: int *B = NULL; int *C = &*B; Turns out C == NULL , and no segfault. So &*B is not actually dereferencing B before taking its address. My guess is that the preprocessor is stripping out instances of &* and *& before they even get to the compiler since they negate each other, but I can't find any documentation to verify whether this is standard C

What is the intended effective ordering of `set -o` options in bash? Does `histexpand` trump `posix`?

核能气质少年 提交于 2019-12-03 13:31:12
I attempted to answer a question a couple hours ago which I believed revealed a somewhat obscure bug in bash POSIX mode . I was hastily and vehemently told this was not so. The contradicting answer, which explicitly says this is not a bug, was selected as the correct answer. So I've been combing over the bash documentation, and I'm still coming away with very much the same impression, so I thought I should ask. My (alleged) bug: set -o histexpand (which is typically implicit) set -o posix echo "#!/" Should, well, echo #!/ . (It does in any other shell). But in bash it instead prints to

What are the differences between the C and C++ preprocessors? [duplicate]

久未见 提交于 2019-12-03 12:07:06
This question already has an answer here: Is a C++ preprocessor identical to a C preprocessor? 3 answers Are there any differences in behaviour between the C and C++ preprocessors? They are defined by different passages of standards text (section 6.10 of the C standard and section 16 of the C++ standard ). My motivation for asking this is that a proposal for making the single quote a digit separator that was recently accepted into C++14 extends the C++ preprocessor grammar to accomodate this change (specifically, it extends the definition of a pp-number ), and I'm wondering whether this

The actual result of name resolution in the class template is different from the c++ 03 standard

﹥>﹥吖頭↗ 提交于 2019-12-03 10:44:43
I test the code in the c++ standard ISO/IEC 14882-03 14.6.1/9 on Xcode 4.1 and Visual Studio 2008. The outputs of the two compiler are both different from the expected result of the standard. The code is pasted below. #include <stdio.h> #include <iostream> using namespace std; void f(char); template <class T > void g(T t) { f(1); f(T(1)); f(t); } void f(int); void h() { g(2); g('a'); } void f(int) { cout << "f int" << endl; } void f(char) { cout << "f char" << endl; } int main() { h(); return 0; } As the description of the standard. The expected output should be f char f int f int f char f

Why is it forbidden to open multiple namespaces at a stretch?

让人想犯罪 __ 提交于 2019-12-03 10:17:16
It's possible to do using namespace foo::bar; (i.e., using the inner namespace without using the outer namespace first / at all), why does the standard forbid to do the following? namespace foo::bar { // open nested namespace bar in foo and extend it... } I'm not looking for a workaround, just a possible rational on why this isn't allowed. I'm not sure "forbidden" is the right word - maybe it was just an oversight. It's a fairly small nice-to-have which isn't really a big deal. You could also take the point of view that the namespace foo isn't created yet when you write foo::bar , so allowing

Is there an “official”/standard CSS3 gradient syntax?

隐身守侯 提交于 2019-12-03 09:59:57
I know there is -webkit-gradient and -moz-linear-gradient . But what is the standard way of defining a gradient? Like there is: -webkit-border-radius and -moz-border-radius and the standard is meant to be border-radius . An update for 2011, the Mozilla syntax is now the 'official' one, adopted by the CSS3 Image Values and Replaced Content Working Draft . Webkit has been updated to use this syntax too, and this has now been incorporated into the latest versions of Chrome and Safari. Kyle Not yet, the two examples you provided are the only coded gradients available as yet, as far as I know. Most

Does the C++11 standard guarantee identical random numbers for the same seed across implementations?

北城以北 提交于 2019-12-03 09:51:52
For example if I instantiate a std::mt19937 with the exact same seed and parameters under GCC and under MSVC, should I get the same sequence of random numbers? If so I assume this property would hold for mersenne_twister_engine in general since mt19937 is just one with specific parameters. This is not true for rand() in C. It looks like the standard documents the transformations applied in terms of specific code, so I suspect it should always be the same, but the devil is in the details... For the new random number engines, yes, for the same seed and parameters you'll get the same sequence of

Should this be ambiguous or not? (implicit casts)

荒凉一梦 提交于 2019-12-03 09:37:57
struct A { A(const A& src); A(const char* src); }; struct B { operator A(); operator char*(); }; void test() { B v; A s(v); } EDG/Comeau and MSVC allows the code while GCC 4.4.4, CLANG and BCC reject it as ambiguous. A C++ committee member replied with this (initially): It's not ambiguous; the A(const A&) constructor is better than the A(const char*) constructor. The const A& parameter binds directly to the result of the conversion function, so the conversion sequence is considered to be a user-defined conversion followed by an identity conversion (13.3.3.1.4p1). The const char* parameter is a

Networking Library in C++14

♀尐吖头ヾ 提交于 2019-12-03 08:40:22
问题 Herb Sutter writes here (on his ISO C++ Spring 2013 meeting trip report) that a networking library is planned to be added to C++14. What features would this library have initially? What is it based on? Is there a proof-of-concept implementation? My Google-fu must be seriously lacking, because I can't even find the proposal draft. There are a series of blog posts on http://meetingcpp.com/ listing the proposals for C++14: part 1, part 2, part 3 and part 4. Among all these, I can only find two

What size should I allow for strerror_r?

≡放荡痞女 提交于 2019-12-03 08:12:51
问题 The OpenGroup POSIX.1-2001 defines strerror_r, as does The Linux Standard Base Core Specification 3.1. But I can find no reference to the maximum size that could be reasonably expected for an error message. I expected some define somewhere that I could put in my code but there is none that I can find. The code must be thread safe. Which is why strerror_r is used and not strerror. Does any one know the symbol I can use? I should I create my own? Example int result = gethostname(p_buffy, size