This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libobjc/28430] objc_write_type(stream, @encode(char*), &char_array) crashes
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jul 2006 09:39:29 -0000
- Subject: [Bug libobjc/28430] objc_write_type(stream, @encode(char*), &char_array) crashes
- References: <bug-28430-12392@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from pinskia at gcc dot gnu dot org 2006-07-19 09:39 -------
This is a bug in your code and not in libobjc or GCC.
The correct code should look like:
#include <objc/Object.h>
#include <stdio.h>
#include <string.h>
int main()
{
char s[80];
char *d = s;
strcpy(s,"Hi world");
TypedStream* stream =
objc_open_typed_stream_for_file("foo",OBJC_WRITEONLY);
objc_write_type(stream, @encode(char*), &d); // crash here
objc_close_typed_stream(stream);
return 0;
}
&s is a pointer to an array and not a pointer to a pointer of chars.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28430