Here is the generated code where strlen of a constant is evaluated at
compile time.
The code:
int main()
{
int len = strlen("abcdef");
printf(("Len is %d\n", len);
Here is the disassembly. I've trimmed and annotated it, but I'll be glad to
send you the code.
ldq $27, __cf_printf($gp)!literal!2 # Load printf address.
mov 6, $0 # load the
strlen("abcdef")
# into register $0 which is
return
value.
ldq $16, $$3($gp)!literal!3 # Load &string for parameter 1.
lda $sp, -16($sp) # adjust stack
stq $26, ($sp) # save return address.
lda $17, -40($16) #
stq $0, 8($sp) # Store len on stack.
lda $18, 8($sp) # computer address in parm3
jsr $26, ($27), __cf_printf!lituse_jsr!2
On 4 Apr 2000, at 22:44, Jerry Feldman wrote:
> What about optimizing compilers that generate inline functions?
> I can't answer that specifically, but there are some optimizations that can
> really get wild, especially in C++.
> "Steven W. Orr" wrote:
> > I beg to heartily differ. *No* C compiler will evaluate a call to strlen
> > at compile time, even if the string is compiletime evaluatable.
--
Jerry Feldman
Contractor, eInfrastructure Partner Engineering
508-467-4315 http://www.testdrive.compaq.com/linux/
Compaq Computer Corp.
200 Forest Street MRO1-3/F1
Marlboro, Ma. 01752
**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************