[GH-ISSUE #1029] gcc false warning in pp.c #630

Closed
opened 2026-10-14 03:16:01 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @magnumripper on GitHub (Jan 18, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1029

Using gcc 4.9.2

In file included from pp.c:64:0:
pp.c: In function 'do_prince_crack':
pp.c:1256:33: warning: array subscript is above array bounds [-Warray-bounds]
       mpz_init_set_si (pw_ks_pos[pw_len], 0);
                                 ^
mpz_int128.h:51:28: note: in definition of macro 'mpz_init_set'
 #define mpz_init_set(x, y) x = y
                            ^
pp.c:1256:7: note: in expansion of macro 'mpz_init_set_si'
       mpz_init_set_si (pw_ks_pos[pw_len], 0);
       ^

This only happens with -O2 and only when not using GMP for PRINCE. This is 100% a red herring. Maybe this is the same compiler bug that produces the false DES warning we saw for years (#276):

DES_std.c: In function 'DES_std_set_key':
DES_std.c:639:17: warning: array subscript is above array bounds [-Warray-bounds]
   while (DES_key[i++]) k += 2;
                 ^
Originally created by @magnumripper on GitHub (Jan 18, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1029 Using gcc 4.9.2 ``` In file included from pp.c:64:0: pp.c: In function 'do_prince_crack': pp.c:1256:33: warning: array subscript is above array bounds [-Warray-bounds] mpz_init_set_si (pw_ks_pos[pw_len], 0); ^ mpz_int128.h:51:28: note: in definition of macro 'mpz_init_set' #define mpz_init_set(x, y) x = y ^ pp.c:1256:7: note: in expansion of macro 'mpz_init_set_si' mpz_init_set_si (pw_ks_pos[pw_len], 0); ^ ``` This only happens with -O2 and only when not using GMP for PRINCE. This is 100% a red herring. Maybe this is the same compiler bug that produces the false DES warning we saw for years (#276): ``` DES_std.c: In function 'DES_std_set_key': DES_std.c:639:17: warning: array subscript is above array bounds [-Warray-bounds] while (DES_key[i++]) k += 2; ^ ```
bsakaguchi 2026-10-14 03:16:01 +07:00
Author
Owner

@magnumripper commented on GitHub (Jan 23, 2015):

Wow, this actually turned out to be a real bug (although not normally triggered). And it's fixed now.

<!-- gh-comment-id:71212547 --> @magnumripper commented on GitHub (Jan 23, 2015): Wow, this actually turned out to be a real bug (although not normally triggered). And it's fixed now.
Author
Owner

@jfoug commented on GitHub (Jan 23, 2015):

What was the fix? I see no commit

<!-- gh-comment-id:71215458 --> @jfoug commented on GitHub (Jan 23, 2015): What was the fix? I see no commit
Author
Owner

@magnumripper commented on GitHub (Jan 24, 2015):

It came and went a couple of time until I realized it. Finally settled in c4db2e81, it was the definitions of pw_ks_pos and pw_ks_cnt. Only a problem if you tried an output length beyond 32, which was never properly supported anyway so is now disallowed...

<!-- gh-comment-id:71310737 --> @magnumripper commented on GitHub (Jan 24, 2015): It came and went a couple of time until I realized it. Finally settled in c4db2e81, it was the definitions of pw_ks_pos and pw_ks_cnt. Only a problem if you tried an output length beyond 32, which was never properly supported anyway so is now disallowed...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#630
No description provided.