This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libobjc/28430] objc_write_type(stream, @encode(char*), &char_array) crashes



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]