language-lawyer
Does printf("%x",1) invoke undefined behavior?
According to the C standard (6.5.2.2 paragraph 6) If the expression that denotes the called function has a type that does not include a[详细]
2023-02-03 13:37 分类:问答The effect of `basic_streambuf::setbuf`
My problem is as follows: Martin York claims in this, this, and this answers that one can make a stringstream read from some piece of memory by using basic_stringbuf::pubsetbuf like this:[详细]
2023-01-28 01:50 分类:问答Where exactly does C++ standard say dereferencing an uninitialized pointer is undefined behavior?
So far I can\'t find how to deduce that the following: int* ptr; *ptr = 0; is undefined behavior. First of all, there\'s 5.3.1/1 that states that * means indirection which converts T* to T. But th[详细]
2023-01-26 21:32 分类:问答Type requirements for std::map
Today I created a map, where the value type has no default constructor. I was surprised that I could not use operator[] to insert the elements to this map, but I had to use the insert method.[详细]
2023-01-26 06:03 分类:问答Defining a function with different signature
Today I discovered that it is possible to declare a function in a header with one signature, and implement it in the source file with different (similar) signature. For example, like this :[详细]
2023-01-26 04:53 分类:问答A virtual member function is used if it is not pure?
C++03 3.2.2 ...An object or non-overloaded function is used if its name appears in a potentially-evaluated expression. A virtual member function is used if it is not pure...[详细]
2023-01-24 15:18 分类:问答Is a main() required for a C program?
Well the title says it all. Is a main() function absolutely essential for a C program? I am asking开发者_如何转开发 this because I was looking at the Linux kernel code, and I didn\'t see a main() fun[详细]
2023-01-23 15:22 分类:问答anonymous empty untagged classes, structs, unions, and enums
!Disclaimer!: Please note that I am talking about untagged declarations. I know it\'s a possibly informal term and what I mean by it is that the declaration is not a typedef and it does not declare an[详细]
2023-01-23 11:18 分类:问答Representation of negative numbers in C?
How does C represent negative integers? Is it by two\'s complement representation or by using the MSB (most significant bit)?[详细]
2023-01-20 02:34 分类:问答Unsequenced value computations (a.k.a sequence points)
Sorry for opening this topic again, but thinking about this topic itself has started giving me an Undefined Behavior. Want to move into the zone of well-defined behavior.[详细]
2023-01-19 01:41 分类:问答