From: | Daniel Villeneuve <danielv@crt.umontreal.ca> |
Newsgroups: | comp.compilers |
Date: | 3 Aug 1998 17:57:55 -0400 |
Organization: | Compilers Central |
References: | 98-08-011 |
Keywords: | C, C++, performance |
mayan@watson.ibm.com (Mayan Moudgill) writes:
> Some of us were having an argument about the performance of C++
> vs. C programs, and I made the statement that C programs would
> be faster than C++ programs, because of the compilers. The rebuttal
> was that
> "you can always write C++ programs in the C-like subset
> [C + classes + in-lining + const], and the performance
> would be the same".
Besides considering the practical aspects of compiler implementation,
there are also aspects of the C++ language that might affect the way a
C++ compiler deals with C-like code. Taken from the CD2 of C++:
1.8 Program execution
18When calling a function (whether or not the function is inline), there
is a sequence point after the evaluation of all function arguments (if
any) which takes place before execution of any expressions or state-
ments in the function body. There is also a sequence point after the
copying of a returned value and before the execution of any expres-
sions outside the function9). Several contexts in C++ cause evalua-
tion of a function call, even though no corresponding function call
syntax appears in the translation unit. [Example: evaluation of a new
expression invokes one or more allocation and constructor functions;
see _expr.new_. For another example, invocation of a conversion func-
tion (_class.conv.fct_) can arise in contexts in which no function
call syntax appears. ] The sequence points at function-entry and
function-exit (as described above) are features of the function calls
as evaluated, whatever the syntax of the expression that calls the
function might be.
Doesn't this paragraph imply that a C++ compiler is more constrained
that a C compiler when dealing with complex expressions, even if such
expressions only contain C constructs?
--
Daniel Villeneuve
Graduate student in Operations Research
Ecole Polytechnique de Montreal
[I don't think so. C has its own sequence point rules which are similar
to this. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.