standards

Is right shift undefined behavior if the count is larger than the width of the type?

余生颓废 提交于 2019-12-27 11:52:15
问题 I just checked the C++ standard. It seems the following code should NOT be undefined behavior: unsigned int val = 0x0FFFFFFF; unsigned int res = val >> 34; // res should be 0 by C++ standard, // but GCC gives warning and res is 67108863 And from the standard: The value of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type or if E1 has a signed type and a non-negative value, the value of the result is the integral part of the quotient of E1/2^E2. If E1 has a signed type

Is right shift undefined behavior if the count is larger than the width of the type?

孤街醉人 提交于 2019-12-27 11:48:10
问题 I just checked the C++ standard. It seems the following code should NOT be undefined behavior: unsigned int val = 0x0FFFFFFF; unsigned int res = val >> 34; // res should be 0 by C++ standard, // but GCC gives warning and res is 67108863 And from the standard: The value of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type or if E1 has a signed type and a non-negative value, the value of the result is the integral part of the quotient of E1/2^E2. If E1 has a signed type

Does JSON syntax allow duplicate keys in an object?

…衆ロ難τιáo~ 提交于 2019-12-27 08:18:52
问题 Is this valid json? { "a" : "x", "a" : "y" } http://jsonlint.com/ says yes. http://www.json.org/ doesn't say anything about it being forbidden. But obviously it doesn't make much sense, does it? Most implementations probably use a hashtable so it is being overriden anyways. 回答1: From the standard (p. ii): It is expected that other standards will refer to this one, strictly adhering to the JSON text format, while imposing restrictions on various encoding details. Such standards may require

Some questions about tree construction [html spec]

不想你离开。 提交于 2019-12-25 03:59:25
问题 I know that it's not customary to ask a bunch of questions in one, but just each question is interconnected with the previous one. And to ask a bunch of separate questions I think it would be wrong. So the first thing I'd like to start is: As each token is emitted from the tokenizer, the user agent must follow the appropriate steps from the following list, known as the tree construction dispatcher: I correctly understand that the tokenizer will finish its work as soon as it analyzes all the

does POD class object initialization require constructor?

丶灬走出姿态 提交于 2019-12-24 13:15:04
问题 I read following links :- object initialized with and without parentheses types of default constructor diff b/w value,zero and default intilization I have some question which i want to clarify. 1) Given a POD class , say :- class A{ int val; }; If i create an object of type A. A obj; // will this call implicitly defined constructor provided by compiler ? Now as far as my understanding in this case constructor is not called.is it correct? new A(); // value-initialize A, which is zero

clientHeight returns different values depending on the mode IE8 is in

不问归期 提交于 2019-12-24 10:17:30
问题 In a javascript function I use document.body.clientHeight to get the height of the body. Now depending on the mode IE8 is in (i.e quirks or standard), the value is different. Example In quirks, document.body.clientHeight = 800px In standard, document.body.clientHeight = 650px Hope I've made sense. Please help. 回答1: Quirks mode and Standards mode return value is inconsistent. Since you tagged it as jQuery, just use $('body').height() or $(window).height() depending on what you need... it fixes

Reusing Process object and IO redirects in C#

早过忘川 提交于 2019-12-24 09:26:09
问题 I'm using the data ready events of the Process class to get information from the standard output and standard error of a running process. It works great on the first run, but after calling Stop() then Start() to force a restart of the application, I no longer recieve data. I've tried CancelErrorRead() but no luck there. I'm considering just re-instantiating the object every time I need to re-run the app, but it seems silly to need to do that. Any advice on how to re-use a Process object to

Which part of the C++ standard covers calling a method via a null pointer?

≡放荡痞女 提交于 2019-12-24 05:27:12
问题 There are many questions on Stack Overflow that explain that the following is undefined behavior in C++: MyType* p = nullptr; p->DoSomething(); but I can't find one that cites the C++ standard. Which part of the C++11 and/or C++14 standards say that this is undefined behavior? 回答1: C++14 [expr.ref]/2: The expression E1->E2 is converted to the equivalent form (*(E1)).E2 C++14 [expr.unary.op]/1: The unary * operator performs indirection: the expression to which it is applied shall be a pointer

JQuery parameter injection on bind/click vs. embedded click handlers with parameters

女生的网名这么多〃 提交于 2019-12-24 04:54:10
问题 So the old JavaScript aficionado and the young jQuery wizard in me are having a little disagreement. Sorry for the long setup, but the heart of the issue is whether to embed onClick code directly in my HTML or to go jQuery-style and and use bind() or click() . I find myself & myself disagreeing on this topic quite often, so I thought I would try generate some discussion on the issue. To explain the issue, the pattern below seems to bring this to the forefront most often. Typical Example I'm

Does the boost::hold_any constructor have undefined behavior?

依然范特西╮ 提交于 2019-12-24 02:21:31
问题 I looked through the boost::hold_any file and I found something what confuses me. if I consider the informations I got through the answers to my question: What happens if you call a destructor and use the allocated memory again for other objects? (In the answer by Mike Seymour) then it is "forbidden" to manipulate the memory of an object which weren't released and reallocated yet, to place there a new object of a different type. I always thought the boost library sticks to the standard, but