[Bug c/125226] error: conflicting types for ‘__stack_chk_guard’; have ‘long unsigned int’

2026-06-16 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125226

H.J. Lu  changed:

   What|Removed |Added

   Target Milestone|--- |17.0
 Resolution|--- |FIXED
 Status|UNCONFIRMED |RESOLVED

--- Comment #4 from H.J. Lu  ---
Fixed.

[Bug c/125226] error: conflicting types for ‘__stack_chk_guard’; have ‘long unsigned int’

2026-06-16 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125226

--- Comment #3 from GCC Commits  ---
The master branch has been updated by H.J. Lu :

https://gcc.gnu.org/g:fa69425e64d9850b0e64a53b15545bdcdbedcd69

commit r17-1597-gfa69425e64d9850b0e64a53b15545bdcdbedcd69
Author: H.J. Lu 
Date:   Fri May 8 12:20:02 2026 +0800

SSP: Check UINTPTR_TYPE to get uintptr_t type

default_stack_protect_guard calls

  lang_hooks.types.type_for_mode (ptr_mode, 1);

to get an integer type for __stack_chk_guard which is declared as a
global symbol of type uintptr_t.  For 32-bit systems, uintptr_t may
be either unsigned int or unsigned long int.  On 32-bit Darwin, we get

$ cat /tmp/x.c
__UINTPTR_TYPE__ __stack_chk_guard = 0x1000;
$ ./xgcc -B./ -S /tmp/x.c -m32
/tmp/x.c:1:18: error: conflicting types for â__stack_chk_guardâ; have
âlong unsigned intâ
1 | __UINTPTR_TYPE__ __stack_chk_guard = 0x1000;
  |  ^
cc1: note: previous declaration of â__stack_chk_guardâ with type
âunsigned intâ
$

since lang_hooks.types.type_for_mode returns unsigned int while Darwin's
uintptr_t is unsigned long int.  Update default_stack_protect_guard to
call unsigned_integer_tree_node_for_type with UINTPTR_TYPE to get unsigned
integer type for uintptr_t instead.

gcc/

PR c/125226
* targhooks.cc (default_stack_protect_guard): If UINTPTR_TYPE
isn't NULL, call unsigned_integer_tree_node_for_type with
UINTPTR_TYPE to get unsigned integer type for uintptr_t.
* tree.cc (unsigned_integer_tree_node_for_type): New function.
(build_common_tree_nodes): Call unsigned_integer_tree_node with
SIZE_TYPE to get unsigned integer type for size_t.
* tree.h (unsigned_integer_tree_node_for_type): New prototype.

Signed-off-by: H.J. Lu 

[Bug c/125226] error: conflicting types for ‘__stack_chk_guard’; have ‘long unsigned int’

2026-05-07 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125226

H.J. Lu  changed:

   What|Removed |Added

  Attachment #64391|0   |1
is obsolete||

--- Comment #2 from H.J. Lu  ---
Created attachment 64392
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64392&action=edit
A new patch

[Bug c/125226] error: conflicting types for ‘__stack_chk_guard’; have ‘long unsigned int’

2026-05-07 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125226

--- Comment #1 from H.J. Lu  ---
Created attachment 64391
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64391&action=edit
A patch

Testing this.