This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pablogsal
Recipients David.Edelsohn, Michael.Felt, lys.nikolaou, pablogsal, skrah
Date 2020-07-06.12:05:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1594037129.79.0.483353676195.issue41215@roundup.psfhosted.org>
In-reply-to
Content
This is enough to reproduce the problem:

#include <stdio.h>

typedef struct {
    char *str;
    int type;
} KeywordToken;

static KeywordToken *the_array[] = {
   NULL,
   NULL,
   (KeywordToken[]) {
        {"if", 510},
        {"in", 518},
        {"as", 520},
        {"is", 527},
        {"or", 532},
        {NULL, -1},
   },
   NULL,
   NULL,
    (KeywordToken[]) {
        {"del11", 503},
        {"try22", 511},
        {NULL, -1},
    },
    NULL
};


int main() {
   for (int s=0; s<7;s++) {
      KeywordToken *tok = the_array[s];
      printf("--> %i %.*s\n", s,s, tok->str);
   }
   return 0;
}
[cpython (3.9)]$ xlc check_bad.c -o check_bad
[cpython (3.9)]$ ./check_bad
--> 0
--> 1
Segmentation fault (core dumped)


But if you change it to:

#include <stdio.h>

typedef struct {
    char *str;
    int type;
} KeywordToken;

static KeywordToken *the_array[] = {
     (KeywordToken[]) {{NULL, -1}},
     (KeywordToken[]) {{NULL, -1}},
    (KeywordToken[]) {
        {"if", 510},
        {"in", 518},
        {"as", 520},
        {"is", 527},
        {"or", 532},
        {NULL, -1},
    },
    (KeywordToken[]) {{NULL, -1}},
    (KeywordToken[]) {{NULL, -1}},
    (KeywordToken[]) {
        {"del11", 503},
        {"try22", 511},
        {NULL, -1},
    },
    (KeywordToken[]) {{NULL, -1}},
};


int main() {
   for (int s=0; s<7;s++) {
      KeywordToken *tok = the_array[s];
      printf("--> %i %.*s\n", s,s, tok->str);
   }
   return 0;
}

[cpython (3.9)]$ xlc check.c -o check
[cpython (3.9)]$ ./check
--> 0
--> 1
--> 2 if
--> 3
--> 4
--> 5 del11
--> 6
History
Date User Action Args
2020-07-06 12:34:00pablogsalunlinkissue41215 messages
2020-07-06 12:05:29pablogsalsetrecipients: + pablogsal, skrah, David.Edelsohn, Michael.Felt, lys.nikolaou
2020-07-06 12:05:29pablogsalsetmessageid: <1594037129.79.0.483353676195.issue41215@roundup.psfhosted.org>
2020-07-06 12:05:29pablogsallinkissue41215 messages
2020-07-06 12:05:29pablogsalcreate