↧
Comment by CPlus on What are the implications of a 'packed' keyword/feature?
Or use static_assert()
View ArticleComment by CPlus on How about support function return itself?
It is not clear whether you are referring to functions that return a call to the function itself (recursive) or a function that returns the actual function itself.
View ArticleComment by CPlus on What are pros and cons of tagged vs untagged union-types?
I find untagged more useful. I can use them to quickly access certain words or bytes of a larger integer type without any shifts/masks.
View ArticleComment by CPlus on Why is type-punning at compile-time a no-go?
@kaya3 I find it hard to imagine how 'little-endian at runtime but big-endian at compile-time' could be, for example, the compiler has to know ahead of time what endian to put integer constants in the...
View ArticleComment by CPlus on How to support syntax like `a && b = c` for a conditional...
Personally that is less readable than just if(a) b = c;
View ArticleComment by CPlus on Why do compilers typically convert code into abstract...
@apropos So does that mean an optimizing C compiler would have more 'effect' on C code than an optimizing assembly compiler would have on assembly?
View ArticleComment by CPlus on What should be the precedence of the bitwise operators...
To me it is logical that the bitwise shift operators have high precedence as they are sort of 'equivalent/most similar' to multiplication/exponentiation. And bitwise OR is the most similar to addition...
View ArticleComment by CPlus on Are there any languages where conditions are not...
@kaya3 What if you don't have boolean types at all, and all the 'logical operators' and comparisons are just part of the if statement syntax, and do not exist outside of one? Are any languages like that?
View ArticleWhat alternatives are there for C++ operator overloading syntax?
I noticed C++ has operator overloading syntax with just the operator names:T& operator +(T& lhs, T& rhs) { return /* ... */;}However, there are 2 distinct operators that are both ++ and --....
View ArticleWhat are the potential problems with assignment operators returning the...
Inline assignment is when the assignment operator can return the value of the new-value (right-hand) operand. For example:if ((homedir = getenv("HOME")) == NULL) { // ...}I see inline assignment as a...
View ArticleIf size could be determined at compile time then why could size not be...
In C the sizeof() operator cannot be resolved in preprocessor conditions. If other operators such as + or - can be (so long as the operands are constants) then what is different about sizeof()?What...
View ArticleWhy would accessing uninitialized memory necessarily be undefined behavior?
In C, accessing any indeterminate/uninitialized memory is undefined behavior, period. Even in the case that the type in question is guaranteed to have no trap representations, such as unsigned char or...
View ArticleWhy does the C library include fgetpos()/fsetpos() if the same functionality...
C includes 2 methods for saving the position of a stream and setting it later. Using fseek() and ftell():long pos = ftell(file);// ...fseek(file, pos, SEEK_SET);Or fgetpos() and fsetpos():fpos_t...
View ArticleWould a structure ever require padding beyond what is required to align the...
In C a structure can have an arbitrary amount of padding. In theory this implementation conforms to the C standard:struct X { int x; // 1000000000 bytes padding};// sizeof(struct X) == 1000000004Is...
View ArticleHow can a programming language support vectorization portably?
C and C++ have no vector types or operations but many compilers offer their own non-portable extensions such as __attribute__((__ext_vector_type__())). The issue is vector types corresponding to vector...
View ArticleWhy do relational comparison operators never short-circuit?
I just thought about the possibility for the less-than and-greater than operators to short-circuit. That is, they can skip evaluating their second operand if the value of the second operand logically...
View ArticleWhat optimizations does the strict aliasing rule facilitate?
This question is tangentially related to: Why is type reinterpretation considered highly problematic in many programming languages?Regardless how 'problematic' type reinterpretation is, why do some...
View ArticleWhy is type reinterpretation considered highly problematic in many...
C++ disallows reinterpret_cast from int to float as far as I know, and using a union or pointer cast to reinterpret an int to a float or vice versa or even an int to a short[2] is undefined behavior....
View ArticleCan regex be compiled into efficient machine code?
Most languages that have regex have a regex parsing library that interprets the regex at runtime and matches them to strings. I am a fan of eliminating as much runtime overhead as possible, and as...
View ArticleWhat obstacles prevented C and C++ from standardizing π?
C does not even have M_PI standardized. C++ only added std::numbers::pi very recently. Yes, the fact that this took so long does hint at some issues. Both languages have an upper bound to their...
View Article
More Pages to Explore .....