Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22097

qemu: uncaught target signal 11 (Segmentation fault) - core dumped, when trying to return a struct

$
0
0

I just noticed that I am unable to have a function return a struct.
I am running this on ARM32/debian docker image with threads enabled.

This is the function that gives me the run time error:

struct CEC_call des_CEC_call(char * buffy){

    char request        =   buffy[0];   //  fails here
    buffy+=4;

    char obligation     =   buffy[1];
    buffy+=4;

    struct CEC_call ceccall;
    pepcall.request     = request;
    pepcall.obligation  =   obligation;

    return ceccall;

}  

But if I change the return type to void, there is no issue in running:

void des_CEC_call(char * buffy){

    char request        =   buffy[0];   //  doesn't fail here
    buffy+=4;

    char obligation     =   buffy[1];
    buffy+=4;

    struct CEC_call ceccall;
    pepcall.request     = request;
    pepcall.obligation  =   obligation; 

}

Return works fine as well with any of the standard return types.

Header where the struct is defined is included in the file with the function although it will still crash even if the struct is defined in the same file. Not sure how to proceed with debugging, any help appreciated.


Viewing all articles
Browse latest Browse all 22097

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>