Re: missing optimization - don't compute return value not used?

2007-09-26 Thread Richard Li
In version 1, the return type is "a_t", so a class construction is required there (the caller will then destruct the returned object). Construction and destruction can have side effects, so the compiler would not drop them. For the following code, template inline a_t& append (a_t & a, b_t const& b

Re: missing optimization - don't compute return value not used?

2007-09-26 Thread Richard Li
Right, page 211 of the C++ standard (2003) explains when copy-ctor and dtor are allowed to be optimized away. But the two circumstances are both like this: A is constructed; A is copy-constructed to B; A is destructed Here A is a temporary object in some sense, and the standard allows for directly

Re: Is this a bug?

2007-09-29 Thread Richard Li
It's not a bug. It conforms the C standard. C, unlike C++, distinguishes functions ONLY by name, not by arguments. C allows calling functions that are not declared by assuming they return int. So GCC would assume that the prototype of "func" to be "int func()" when compiling "main.c", and can gene