standards

Should we bother about IE < 8?

大憨熊 提交于 2019-12-20 04:38:06
问题 It might look like philosophical question, however it really bother me. We're expecting HTML 5, we're using JS, Ajax, Flex, all this stuff, but when older browsers were developed, no one even dreamed about such technologies. IE6 can't see transparency in PNG's. Some correct W3C techniques, are bad interpretations by IE6. It's just too old for our "new" world. IE7 is sight better better than IE6, but it still has some weird errors. How many people use IE6 now? And if someone upgraded it to IE7

Are “Statement and Declarations in Expressions” specific to GNU C?

时光总嘲笑我的痴心妄想 提交于 2019-12-20 04:16:21
问题 Are Statement and Declarations in Expressions specific to GNU C ? Or this feature is also included in C99 standard ? 回答1: It's a GCC extension. (See the GCC docs, e.g. here for gcc 4.3.3, for a full list of GCC extensions; and the C99 spec is available here.) GCC will warn about such things if you use the -pedantic -std=c99 flags, e.g.: $ cat foo.c int main(void) { return ({ int a = 0; a; }); } $ gcc -pedantic -std=c99 -c foo.c foo.c: In function 'main': foo.c:3: warning: ISO C forbids braced

C++ primary expressions - Is it primary expression or not?

自古美人都是妖i 提交于 2019-12-19 21:53:45
问题 Why are they called "primary"? In the order of evaluence they are the first? C++03 standard defines the expression in chapter 5 (Note 1): An expression is a sequence of operators and operands that specifies a computation. Then the 5.1 "Primary expressions" defines the list of primary expressions: (1) primary-expression: literal this ( expression ) id-expression My main question is in connection the third point: ( expression ) So, according to the standard, every expression with brackets are

Should an empty base class affect the layout of the derived class?

≡放荡痞女 提交于 2019-12-19 19:53:12
问题 The C++ standard (quoting from draft n3242) says the following about subobjects [intro.object]: Unless an object is a bit-field or a base class subobject of zero size, the address of that object is the address of the first byte it occupies. Two distinct objects that are neither bit-fields nor base class subobjects of zero size shall have distinct addresses. Now, given the following snippet: struct empty { }; struct member: empty { }; struct derived: empty { member m; }; int main(void) {

Why does C++ list initialization also take regular constructors into account?

余生颓废 提交于 2019-12-19 19:02:18
问题 In C++ when using initializer_list syntax to initialize an object, the regular constructors of the object also participate in overload resolution, when no other list initialization rule applies. As far as I understand it, the following code calls X::X(int) class X { int a_; X(int a):a_(a) {} ); void foo() { X bar{3}; } But I don't understand, why regular constructors also are considered in context of initializer_lists. I feel that a lot of programmers now write X{3} to call a constructor

C And C++ Coding Standards

此生再无相见时 提交于 2019-12-19 16:47:35
问题 What are best practices with regards to C and C++ coding standards? Should developers be allowed to willy-nilly mix them together. Are there any complications when linking C and C++ object files. Should things like socket libraries that traditionally is written in C remain in C and kept in seperate source files? That is keeping c code in .c files and c++ code in .cpp files. When mixing c and C++ after being parsed with g++ will there be any performance penalties, since typesafe checks are not

What is the result of casting float +INF, -INF, and NAN to integer in C?

只愿长相守 提交于 2019-12-19 13:12:55
问题 Does any standard specifies what should be the output? For example this code: #include <stdio.h> #include <math.h> int main(int argc, char** argv) { float a = INFINITY; float b = -INFINITY; float c = NAN; printf("float %f %f %f\n", a, b, c); printf("int %d %d %d\n", (int) a, (int) b, (int) c); printf("uint %u %u %u\n", (unsigned int) a, (unsigned int) b, (unsigned int) c); printf("lint %ld %ld %ld\n", (long int) a, (long int) b, (long int) b); printf("luint %lu %lu %lu\n", (unsigned long int)

What is the result of casting float +INF, -INF, and NAN to integer in C?

半腔热情 提交于 2019-12-19 13:11:12
问题 Does any standard specifies what should be the output? For example this code: #include <stdio.h> #include <math.h> int main(int argc, char** argv) { float a = INFINITY; float b = -INFINITY; float c = NAN; printf("float %f %f %f\n", a, b, c); printf("int %d %d %d\n", (int) a, (int) b, (int) c); printf("uint %u %u %u\n", (unsigned int) a, (unsigned int) b, (unsigned int) c); printf("lint %ld %ld %ld\n", (long int) a, (long int) b, (long int) b); printf("luint %lu %lu %lu\n", (unsigned long int)

Is it legal C++ to pass the address of a static const int with no definition to a template?

本秂侑毒 提交于 2019-12-19 10:25:57
问题 I'm having trouble deciding whether not this code should compile or if just both compilers I tried have a bug (GCC 4.2 and Sun Studio 12). In general, if you have a static class member you declare in a header file you are required to define it in some source file. However, an exception is made in the standard for static const integrals. For example, this is allowed: #include <iostream> struct A { static const int x = 42; }; With no need to add a definition of x outside the class body

pre and post increment operations on a variable give different output on TC and gcc [duplicate]

蹲街弑〆低调 提交于 2019-12-19 09:44:22
问题 This question already has answers here : Why are these constructs using pre and post-increment undefined behavior? (14 answers) Closed last year . Here is my simple code ... #include<stdio.h> int main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); return 0; } On gcc,it gives output as '4 5 5 5 5' but on TC,it gives output as '4 5 5 4 5' what I know that in printf statement,evaluation will be from left to right if it is a single expression but in normal statement,it will be from