Message373121
Glad you figured it out!
I doubt I would have. Thx!!
On 06/07/2020 14:37, Pablo Galindo Salgado wrote:
> Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:
>
> 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\n",s);
> if (tok == NULL) {
> continue;
> }
> 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
> --> 2
> 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];
> if (tok == NULL) {
> continue;
> }
> 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
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue41215>
> _______________________________________
> |
|
Date |
User |
Action |
Args |
2020-07-06 14:30:15 | Michael.Felt | set | recipients:
+ Michael.Felt, skrah, David.Edelsohn, lys.nikolaou, pablogsal |
2020-07-06 14:30:15 | Michael.Felt | link | issue41215 messages |
2020-07-06 14:30:15 | Michael.Felt | create | |
|