Re: Runtime errors possible when I forgot include <string.h>
- From: Marc Boyer <Marc.Boyer@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 25 Oct 2005 09:15:53 +0000 (UTC)
Le 25-10-2005, ABeck <alexander.beck-ratzka@xxxxxxxxxx> a écrit :
> I have ar more or less academical question.
>
> Can there arise runtime errors in a program, if the include of
><string.h> has been forgotten? If all the arguments to the functions of
><string.h> are correct, is it possible that an error occurs, and what
> an error might this be?
Without include of <string.h>, all functions are 'implicitely
defined', that is return value is supposed to be int and
parameters are converted using 'default argument promotion'
(6.5.2.2/6), ie integer promotion and float->double.
So, the generated code could be incompatible with the
implementation (UB). If implicit conversion between
int and char* is unsafe (sizeof(int) < sizeof(char*)
for example), then, strange things will occur.
But, in most platform, implict conversion
between int and char* behaves in a way such that
the code runs.
Marc Boyer
.
- Follow-Ups:
- Re: Runtime errors possible when I forgot include <string.h>
- From: Peter Nilsson
- Re: Runtime errors possible when I forgot include <string.h>
- From: Jordan Abel
- Re: Runtime errors possible when I forgot include <string.h>
- From: Joe Estock
- Re: Runtime errors possible when I forgot include <string.h>
- References:
- Prev by Date: Runtime errors possible when I forgot include <string.h>
- Next by Date: Re: "a < b < c" not the same as "(a < b) && (b < c)"?
- Previous by thread: Runtime errors possible when I forgot include <string.h>
- Next by thread: Re: Runtime errors possible when I forgot include <string.h>
- Index(es):
Relevant Pages
|