public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine
@ 2022-11-20 13:00 eaneiros at gmail dot com
  2022-12-08 20:32 ` [Bug c++/107768] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: eaneiros at gmail dot com @ 2022-11-20 13:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

            Bug ID: 107768
           Summary: Bogus -Wzero-as-null-pointer-constant in coroutine
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eaneiros at gmail dot com
  Target Milestone: ---

Created attachment 53930
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53930&action=edit
Sample code

I was trying one of the cppreference coroutine examples and encountered what
appears to be a false positive for -Wzero-as-null-pointer-constant. See
attached for sample code.

According to godbolt.org this happens in gcc trunk. To trigger it just compile
with -Wzero-as-null-pointer-constant.

Godbolt link: https://godbolt.org/z/41aMEErx4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/107768] Bogus -Wzero-as-null-pointer-constant in coroutine
  2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
@ 2022-12-08 20:32 ` pinskia at gcc dot gnu.org
  2022-12-08 21:02 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-08 20:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 54050
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54050&action=edit
Reduced testcase

This reduces the testcase to the bare min to reproduce the wrong warning.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/107768] Bogus -Wzero-as-null-pointer-constant in coroutine
  2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
  2022-12-08 20:32 ` [Bug c++/107768] " pinskia at gcc dot gnu.org
@ 2022-12-08 21:02 ` pinskia at gcc dot gnu.org
  2022-12-08 21:28 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-08 21:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
#1  0x000000000106a451 in maybe_warn_zero_as_null_pointer_constant
(expr=<non_lvalue_expr 0x7ffff6e36420>, loc=16802880) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/tree.cc:6247
#2  0x0000000000c5b243 in conversion_null_warnings (totype=<pointer_type
0x7ffff6de8f18>, expr=<non_lvalue_expr 0x7ffff6e36420>, fn=<function_decl
0x7ffff6dd9300 __ct_comp >, argnum=0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.cc:8013
#3  0x0000000000c5c0df in convert_like_internal (convs=0x4c264b0,
expr=<non_lvalue_expr 0x7ffff6e36420>, fn=<function_decl 0x7ffff6dd9300
__ct_comp >, argnum=0, issue_conversion_warnings=true, c_cast_p=false,
nested_p=false, complain=3) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.cc:8234
#4  0x0000000000c5e811 in convert_like (convs=0x4c264b0, expr=<non_lvalue_expr
0x7ffff6e36420>, fn=<function_decl 0x7ffff6dd9300 __ct_comp >, argnum=0,
issue_conversion_warnings=true, c_cast_p=false, nested_p=false, complain=3) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.cc:8762
#5  0x0000000000c5e8cc in convert_like_with_context (convs=0x4c264b0,
expr=<non_lvalue_expr 0x7ffff6e36420>, fn=<function_decl 0x7ffff6dd9300
__ct_comp >, argnum=0, complain=3) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.cc:8788
#6  0x0000000000c6375f in build_over_call (cand=0x4c264e0, flags=17,
complain=3) at /home/apinski/src/upstream-gcc/gcc/gcc/cp/call.cc:9936
#7  0x0000000000c5c7b5 in convert_like_internal (convs=0x4c26610,
expr=<non_lvalue_expr 0x7ffff6e36420>, fn=<function_decl 0x7ffff6dd9b00
operator==>, argnum=1, issue_conversion_warnings=true, c_cast_p=false,
nested_p=false, complain=3) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.cc:8302
#8  0x0000000000c5e811 in convert_like (convs=0x4c26610, expr=<non_lvalue_expr
0x7ffff6e36420>, fn=<function_decl 0x7ffff6dd9b00 operator==>, argnum=1,
issue_conversion_warnings=true, c_cast_p=false, nested_p=false, complain=3) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.cc:8762
#9  0x0000000000c5e8cc in convert_like_with_context (convs=0x4c26610,
expr=<non_lvalue_expr 0x7ffff6e36420>, fn=<function_decl 0x7ffff6dd9b00
operator==>, argnum=1, complain=3) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.cc:8788
#10 0x0000000000c6375f in build_over_call (cand=0x4c26640, flags=1, complain=3)
at /home/apinski/src/upstream-gcc/gcc/gcc/cp/call.cc:9936
#11 0x0000000000c5737f in build_new_op (loc=..., code=EQ_EXPR, flags=1,
arg1=<view_convert_expr 0x7ffff6e36400>, arg2=<non_lvalue_expr 0x7ffff6e36420>,
arg3=<tree 0x0>, lookups=<tree 0x0>, overload=0x7fffffffcf18, complain=3) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.cc:6986
#12 0x000000000108fc84 in build_x_binary_op (loc=..., code=EQ_EXPR,
arg1=<view_convert_expr 0x7ffff6e36400>, arg1_code=ERROR_MARK,
arg2=<non_lvalue_expr 0x7ffff6e36420>, arg2_code=ERROR_MARK, lookups=<tree
0x0>, overload_p=0x7fffffffcfb8, complain=3) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/typeck.cc:4722
#13 0x0000000000ee2dde in cp_parser_binary_expression (parser=0x7ffff7274be0,
cast_p=false, no_toplevel_fold_p=false, decltype_p=false,
prec=PREC_NOT_OPERATOR, pidk=0x0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:10280
#14 0x0000000000ee337a in cp_parser_assignment_expression
(parser=0x7ffff7274be0, pidk=0x0, cast_p=false, decltype_p=false) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:10441
#15 0x0000000000ee3704 in cp_parser_expression (parser=0x7ffff7274be0,
pidk=0x0, cast_p=false, decltype_p=false, warn_comma_p=false) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:10611
#16 0x0000000000eedaea in cp_parser_jump_statement (parser=0x7ffff7274be0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:14356
#17 0x0000000000ee8970 in cp_parser_statement (parser=0x7ffff7274be0,
in_statement_expr=<tree 0x0>, in_compound=true, if_p=0x0, chain=0x0,
loc_after_labels=0x0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:12332
#18 0x0000000000ee9c92 in cp_parser_statement_seq_opt (parser=0x7ffff7274be0,
in_statement_expr=<tree 0x0>) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:12906
#19 0x0000000000ee9b74 in cp_parser_compound_statement (parser=0x7ffff7274be0,
in_statement_expr=<tree 0x0>, bcs_flags=0, function_body=true) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:12858
#20 0x0000000000f0464c in cp_parser_function_body (parser=0x7ffff7274be0,
in_function_try_block=false) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:25241
#21 0x0000000000f04970 in cp_parser_ctor_initializer_opt_and_function_body
(parser=0x7ffff7274be0, in_function_try_block=false) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:25292
#22 0x0000000000f12fff in cp_parser_function_definition_after_declarator
(parser=0x7ffff7274be0, inline_p=false) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:31902
#23 0x0000000000f12e10 in
cp_parser_function_definition_from_specifiers_and_declarator
(parser=0x7ffff7274be0, decl_specifiers=0x7fffffffd7f0, attributes=<tree_list
0x7ffff6e2feb0>, declarator=0x4c16450) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:31819
#24 0x0000000000efebc5 in cp_parser_init_declarator (parser=0x7ffff7274be0,
flags=0, decl_specifiers=0x7fffffffd7f0, checks=0x0,
function_definition_allowed_p=true, member_p=false, declares_class_or_enum=0,
function_definition_p=0x7fffffffd779, maybe_range_for_decl=0x0,
init_loc=0x7fffffffd780,
    auto_result=0x7fffffffd788) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:22693
#25 0x0000000000eefdd6 in cp_parser_simple_declaration (parser=0x7ffff7274be0,
function_definition_allowed_p=true, maybe_range_for_decl=0x0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:15341
#26 0x0000000000eef8cf in cp_parser_block_declaration (parser=0x7ffff7274be0,
statement_p=false) at /home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:15161
#27 0x0000000000eef51d in cp_parser_declaration (parser=0x7ffff7274be0,
prefix_attrs=<tree 0x0>) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:15027
#28 0x0000000000eef5e9 in cp_parser_toplevel_declaration
(parser=0x7ffff7274be0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:15048
#29 0x0000000000eeeaef in cp_parser_declaration_seq_opt (parser=0x7ffff7274be0)
at /home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:14799
#30 0x0000000000efbf28 in cp_parser_namespace_body (parser=0x7ffff7274be0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:21498
#31 0x0000000000efbebd in cp_parser_namespace_definition
(parser=0x7ffff7274be0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:21476
#32 0x0000000000eef3f6 in cp_parser_declaration (parser=0x7ffff7274be0,
prefix_attrs=<tree 0x0>) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:15007
#33 0x0000000000eef5e9 in cp_parser_toplevel_declaration
(parser=0x7ffff7274be0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:15048
#34 0x0000000000ed74fc in cp_parser_translation_unit (parser=0x7ffff7274be0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:5090
#35 0x0000000000f4e06b in c_parse_file () at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:49349
#36 0x000000000115200a in c_common_parse_file () at
/home/apinski/src/upstream-gcc/gcc/gcc/c-family/c-opts.cc:1248
#37 0x000000000197da00 in compile_file () at
/home/apinski/src/upstream-gcc/gcc/gcc/toplev.cc:444
#38 0x0000000001980acd in do_compile (no_backend=false) at
/home/apinski/src/upstream-gcc/gcc/gcc/toplev.cc:2125
#39 0x0000000001980eb5 in toplev::main (this=0x7fffffffdd62, argc=5,
argv=0x7fffffffde68) at /home/apinski/src/upstream-gcc/gcc/gcc/toplev.cc:2277
#40 0x0000000003293c49 in main (argc=5, argv=0x7fffffffde68) at
/home/apinski/src/upstream-gcc/gcc/gcc/main.cc:39

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/107768] Bogus -Wzero-as-null-pointer-constant in coroutine
  2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
  2022-12-08 20:32 ` [Bug c++/107768] " pinskia at gcc dot gnu.org
  2022-12-08 21:02 ` pinskia at gcc dot gnu.org
@ 2022-12-08 21:28 ` pinskia at gcc dot gnu.org
  2022-12-08 22:28 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-08 21:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-12-08
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
 <view_convert_expr 0x7ffff6e36400
    type <record_type 0x7ffff6ded1f8 partial_ordering needs-constructing
cxx-odr-p type_1 type_5 type_6 QI
        size <integer_cst 0x7ffff72680c0 constant 8>
        unit-size <integer_cst 0x7ffff72680d8 constant 1>
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6ded1f8
        fields <function_decl 0x7ffff73d9c00 __dt  type <method_type
0x7ffff6df0150>
            public abstract external in_system_header autoinline decl_3 decl_8
QI /home/apinski/upstream-gcc/include/c++/13.0.0/compare:61:9 align:16
warn_if_not_align:0 context <record_type 0x7ffff6ded1f8 partial_ordering>
            full-name "constexpr std::partial_ordering::~partial_ordering()
noexcept (<uninstantiated>)"
            not-really-extern chain <function_decl 0x7ffff6e04100 __dt_base >>
context <namespace_decl 0x7ffff7263098 std>
        full-name "class std::partial_ordering"
        needs-constructor X(constX&) this=(X&) n_parents=0 use_template=0
interface-unknown
        pointer_to_this <pointer_type 0x7ffff6ded348> reference_to_this
<reference_type 0x7ffff6df09d8> chain <type_decl 0x7ffff6dec2f8
partial_ordering>>
    public
    arg:0 <parm_decl 0x7ffff6e32b00 __cmp type <record_type 0x7ffff6ded1f8
partial_ordering>
        addressable used read QI
/home/apinski/upstream-gcc/include/c++/13.0.0/compare:358:26 size <integer_cst
0x7ffff72680c0 8> unit-size <integer_cst 0x7ffff72680d8 1>
        align:8 warn_if_not_align:0 context <function_decl 0x7ffff6e34600
is_eq> arg-type <record_type 0x7ffff6ded1f8 partial_ordering>>
    /home/apinski/upstream-gcc/include/c++/13.0.0/compare:359:12 start:
/home/apinski/upstream-gcc/include/c++/13.0.0/compare:359:12 finish:
/home/apinski/upstream-gcc/include/c++/13.0.0/compare:359:16>


Is looking exactly like PR 95242 ...

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/107768] Bogus -Wzero-as-null-pointer-constant in coroutine
  2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
                   ` (2 preceding siblings ...)
  2022-12-08 21:28 ` pinskia at gcc dot gnu.org
@ 2022-12-08 22:28 ` pinskia at gcc dot gnu.org
  2022-12-08 22:29 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-08 22:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Oh I was printing the backtrace of the wrong one :)

Breakpoint 5, warning_at (location=21406144, opt=860, gmsgid=0x36bec84 "zero as
null pointer constant") at
/home/apinski/src/upstream-gcc/gcc/gcc/diagnostic.cc:1875
1875    {
1: expand_location( location) = {file = 0x4c16150 "t.cc", line = 24, column =
1, data = 0x0, sysp = false}
(gdb) bt
#0  warning_at (location=21406144, opt=860, gmsgid=0x36bec84 "zero as null
pointer constant") at /home/apinski/src/upstream-gcc/gcc/gcc/diagnostic.cc:1875
#1  0x000000000106a451 in maybe_warn_zero_as_null_pointer_constant
(expr=<integer_cst 0x7ffff7268360>, loc=21406144) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/tree.cc:6247
#2  0x0000000000d29f62 in cp_convert_to_pointer (type=<pointer_type
0x7ffff6c24f18>, expr=<integer_cst 0x7ffff7268360>, dofold=true, complain=3) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/cvt.cc:213
#3  0x0000000000d2d1dc in ocp_convert (type=<pointer_type 0x7ffff6c24f18>,
expr=<integer_cst 0x7ffff7268360>, convtype=79, flags=17, complain=3) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/cvt.cc:887
#4  0x0000000000d2fc39 in convert (type=<pointer_type 0x7ffff6c24f18>,
expr=<integer_cst 0x7ffff7268360>) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/cvt.cc:1688
#5  0x0000000000d1d930 in cp_fold (x=<convert_expr 0x7ffff6e56980>) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/cp-gimplify.cc:2515
#6  0x0000000000d1601b in cp_fold_r (stmt_p=0x7ffff6c277a0,
walk_subtrees=0x7fffffffd3e0, data_=0x7fffffffd540) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/cp-gimplify.cc:1017
#7  0x0000000001dd730d in walk_tree_1 (tp=0x7ffff6c277a0, func=0xd157dc
<cp_fold_r(tree*, int*, void*)>, data=0x7fffffffd540, pset=0x0, lh=0x1065f71
<cp_walk_subtrees(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)>)
    at /home/apinski/src/upstream-gcc/gcc/gcc/tree.cc:11257
#8  0x0000000001dd78ab in walk_tree_1 (tp=0x7ffff6c210c0, func=0xd157dc
<cp_fold_r(tree*, int*, void*)>, data=0x7fffffffd540, pset=0x0, lh=0x1065f71
<cp_walk_subtrees(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)>)
    at /home/apinski/src/upstream-gcc/gcc/gcc/tree.cc:11361
#9  0x0000000000d1690a in cp_fold_function (fndecl=<function_decl
0x7ffff6c21000 resuming_on_new_thread>) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/cp-gimplify.cc:1133
#10 0x0000000000d9f747 in finish_function (inline_p=false) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/decl.cc:18210
#11 0x0000000000f1300a in cp_parser_function_definition_after_declarator
(parser=0x7ffff7274be0, inline_p=false) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:31905
#12 0x0000000000f12e10 in
cp_parser_function_definition_from_specifiers_and_declarator
(parser=0x7ffff7274be0, decl_specifiers=0x7fffffffd9b0, attributes=<tree 0x0>,
declarator=0x4c16320) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:31819
#13 0x0000000000efebc5 in cp_parser_init_declarator (parser=0x7ffff7274be0,
flags=0, decl_specifiers=0x7fffffffd9b0, checks=0x0,
function_definition_allowed_p=true, member_p=false, declares_class_or_enum=0,
function_definition_p=0x7fffffffd939, maybe_range_for_decl=0x0,
init_loc=0x7fffffffd940,
    auto_result=0x7fffffffd948) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:22693
#14 0x0000000000eefdd6 in cp_parser_simple_declaration (parser=0x7ffff7274be0,
function_definition_allowed_p=true, maybe_range_for_decl=0x0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:15341
#15 0x0000000000eef8cf in cp_parser_block_declaration (parser=0x7ffff7274be0,
statement_p=false) at /home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:15161
#16 0x0000000000eef51d in cp_parser_declaration (parser=0x7ffff7274be0,
prefix_attrs=<tree 0x0>) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:15027
#17 0x0000000000eef5e9 in cp_parser_toplevel_declaration
(parser=0x7ffff7274be0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:15048
#18 0x0000000000ed74fc in cp_parser_translation_unit (parser=0x7ffff7274be0) at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:5090
#19 0x0000000000f4e06b in c_parse_file () at
/home/apinski/src/upstream-gcc/gcc/gcc/cp/parser.cc:49349
#20 0x000000000115200a in c_common_parse_file () at
/home/apinski/src/upstream-gcc/gcc/gcc/c-family/c-opts.cc:1248
#21 0x000000000197da00 in compile_file () at
/home/apinski/src/upstream-gcc/gcc/gcc/toplev.cc:444
#22 0x0000000001980acd in do_compile (no_backend=false) at
/home/apinski/src/upstream-gcc/gcc/gcc/toplev.cc:2125
#23 0x0000000001980eb5 in toplev::main (this=0x7fffffffdd62, argc=5,
argv=0x7fffffffde68) at /home/apinski/src/upstream-gcc/gcc/gcc/toplev.cc:2277
#24 0x0000000003293c49 in main (argc=5, argv=0x7fffffffde68) at
/home/apinski/src/upstream-gcc/gcc/gcc/main.cc:39

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/107768] Bogus -Wzero-as-null-pointer-constant in coroutine
  2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
                   ` (3 preceding siblings ...)
  2022-12-08 22:28 ` pinskia at gcc dot gnu.org
@ 2022-12-08 22:29 ` pinskia at gcc dot gnu.org
  2022-12-08 22:34 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-08 22:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(gdb) p debug_tree(decl)
 <var_decl 0x7ffff6c27750 _Coro_frameptr
    type <pointer_type 0x7ffff6c24f18
        type <record_type 0x7ffff6c24e70 _Z22resuming_on_new_threadv.Frame
needs-constructing cxx-odr-p type_5 BLK
            size <integer_cst 0x7ffff6e522e8 constant 320>
            unit-size <integer_cst 0x7ffff6e52390 constant 40>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6c24e70 fields <field_decl 0x7ffff6c23428 _Coro_resume_fn> context
<translation_unit_decl 0x7ffff7250168 t.ii>
            full-name "struct
resuming_on_new_thread()::_Z22resuming_on_new_threadv.Frame"
            needs-constructor X() X(constX&) this=(X&) n_parents=0
use_template=0 interface-unknown
            pointer_to_this <pointer_type 0x7ffff6c24f18> chain <type_decl
0x7ffff6c232f8 _Z22resuming_on_new_threadv.Frame>>
        unsigned DI
        size <integer_cst 0x7ffff7242fc0 constant 64>
        unit-size <integer_cst 0x7ffff7242fd8 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6c24f18>
    unsigned read DI t.cc:15:6 size <integer_cst 0x7ffff7242fc0 64> unit-size
<integer_cst 0x7ffff7242fd8 8>
    align:64 warn_if_not_align:0 context <function_decl 0x7ffff6c21000
resuming_on_new_thread> initial <convert_expr 0x7ffff6e56980> chain <var_decl
0x7ffff6c277e0 _Coro_promise_live>>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/107768] Bogus -Wzero-as-null-pointer-constant in coroutine
  2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
                   ` (4 preceding siblings ...)
  2022-12-08 22:29 ` pinskia at gcc dot gnu.org
@ 2022-12-08 22:34 ` pinskia at gcc dot gnu.org
  2022-12-10 14:04 ` iains at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-08 22:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This should fix the issue (just like what was done in PR 51045):

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 01a3e831ee5..96875425ba6 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -4131,7 +4131,7 @@ coro_rewrite_function_body (location_t fn_start, tree
fnbody, tree orig,
   /* We will need to be able to set the resume function pointer to nullptr
      to signal that the coroutine is 'done'.  */
   tree zero_resume
-    = build1 (CONVERT_EXPR, resume_fn_ptr_type, integer_zero_node);
+    = build1 (CONVERT_EXPR, resume_fn_ptr_type, nullptr_node);

   /* The pointer to the destroy function.  */
   tree var = coro_build_artificial_var (fn_start, coro_destroy_fn_id,
@@ -4518,7 +4518,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree
*destroyer)
   tree ramp_body = push_stmt_list ();

   tree zeroinit = build1_loc (fn_start, CONVERT_EXPR,
-                             coro_frame_ptr, integer_zero_node);
+                             coro_frame_ptr, nullptr_node);
   tree coro_fp = coro_build_artificial_var (fn_start, "_Coro_frameptr",
                                            coro_frame_ptr, orig, zeroinit);
   tree varlist = coro_fp;
@@ -4753,7 +4753,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree
*destroyer)

       gcc_checking_assert (same_type_p (fn_return_type, TREE_TYPE (grooaf)));
       tree if_stmt = begin_if_stmt ();
-      tree cond = build1 (CONVERT_EXPR, coro_frame_ptr, integer_zero_node);
+      tree cond = build1 (CONVERT_EXPR, coro_frame_ptr, nullptr_node);
       cond = build2 (EQ_EXPR, boolean_type_node, coro_fp, cond);
       finish_if_stmt_cond (cond, if_stmt);
       if (VOID_TYPE_P (fn_return_type))

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/107768] Bogus -Wzero-as-null-pointer-constant in coroutine
  2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
                   ` (5 preceding siblings ...)
  2022-12-08 22:34 ` pinskia at gcc dot gnu.org
@ 2022-12-10 14:04 ` iains at gcc dot gnu.org
  2022-12-10 15:55 ` iains at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: iains at gcc dot gnu.org @ 2022-12-10 14:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |iains at gcc dot gnu.org

--- Comment #7 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> This should fix the issue (just like what was done in PR 51045):

yes, as far as my testing goes it does, without regressing our testsuite,
cppcoro or folly.

however, I cannot approve - so it will have to be posted.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/107768] Bogus -Wzero-as-null-pointer-constant in coroutine
  2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
                   ` (6 preceding siblings ...)
  2022-12-10 14:04 ` iains at gcc dot gnu.org
@ 2022-12-10 15:55 ` iains at gcc dot gnu.org
  2022-12-16 20:16 ` cvs-commit at gcc dot gnu.org
  2023-04-30  8:27 ` cvs-commit at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: iains at gcc dot gnu.org @ 2022-12-10 15:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

--- Comment #8 from Iain Sandoe <iains at gcc dot gnu.org> ---
posted:
https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608262.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/107768] Bogus -Wzero-as-null-pointer-constant in coroutine
  2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
                   ` (7 preceding siblings ...)
  2022-12-10 15:55 ` iains at gcc dot gnu.org
@ 2022-12-16 20:16 ` cvs-commit at gcc dot gnu.org
  2023-04-30  8:27 ` cvs-commit at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-16 20:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:0b1d66658ecdcc3d9251641a0b902b4c73ace303

commit r13-4751-g0b1d66658ecdcc3d9251641a0b902b4c73ace303
Author: Andrew Pinski <pinskia@gmail.com>
Date:   Thu Dec 8 22:34:16 2022 +0000

    coroutines: Build pointer initializers with nullptr_node [PR107768]

    The PR reports that using integer_zero_node triggers a warning for
    -Wzero-as-null-pointer-constant which comes from compiler-generated code so
    makes no sense to the end user.

    Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>

            PR c++/107768

    gcc/cp/ChangeLog:

            * coroutines.cc (coro_rewrite_function_body): Initialize pointers
            from nullptr_node.  (morph_fn_to_coro): Likewise.

    gcc/testsuite/ChangeLog:

            * g++.dg/coroutines/pr107768.C: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/107768] Bogus -Wzero-as-null-pointer-constant in coroutine
  2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
                   ` (8 preceding siblings ...)
  2022-12-16 20:16 ` cvs-commit at gcc dot gnu.org
@ 2023-04-30  8:27 ` cvs-commit at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-30  8:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107768

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:

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

commit r12-9500-gdb0985039fa58d5ef5d4ed10d2cbfd5b3ea6b3ee
Author: Andrew Pinski <pinskia@gmail.com>
Date:   Thu Dec 8 22:34:16 2022 +0000

    coroutines: Build pointer initializers with nullptr_node [PR107768]

    The PR reports that using integer_zero_node triggers a warning for
    -Wzero-as-null-pointer-constant which comes from compiler-generated code so
    makes no sense to the end user.

    Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>

            PR c++/107768

    gcc/cp/ChangeLog:

            * coroutines.cc (coro_rewrite_function_body): Initialize pointers
            from nullptr_node.  (morph_fn_to_coro): Likewise.

    gcc/testsuite/ChangeLog:

            * g++.dg/coroutines/pr107768.C: New test.

    (cherry picked from commit 0b1d66658ecdcc3d9251641a0b902b4c73ace303)

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-04-30  8:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-20 13:00 [Bug c++/107768] New: Bogus -Wzero-as-null-pointer-constant in coroutine eaneiros at gmail dot com
2022-12-08 20:32 ` [Bug c++/107768] " pinskia at gcc dot gnu.org
2022-12-08 21:02 ` pinskia at gcc dot gnu.org
2022-12-08 21:28 ` pinskia at gcc dot gnu.org
2022-12-08 22:28 ` pinskia at gcc dot gnu.org
2022-12-08 22:29 ` pinskia at gcc dot gnu.org
2022-12-08 22:34 ` pinskia at gcc dot gnu.org
2022-12-10 14:04 ` iains at gcc dot gnu.org
2022-12-10 15:55 ` iains at gcc dot gnu.org
2022-12-16 20:16 ` cvs-commit at gcc dot gnu.org
2023-04-30  8:27 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).