[Bug libstdc++/91547] std::string_view find_last_not_of can trigger unsigned integer overflow

2022-07-25 Thread vlovich at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91547

Vitali  changed:

   What|Removed |Added

 CC||vlovich at gmail dot com

--- Comment #4 from Vitali  ---
FWIW clang does implement this. Even if the maintainers disagree on the utility
in practice, does feature parity for command-line options with Clang change the
calculus?

[Bug libstdc++/91547] std::string_view find_last_not_of can trigger unsigned integer overflow

2022-07-25 Thread vlovich at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91547

--- Comment #5 from Vitali  ---
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

[Bug c++/102051] New: [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848

2021-08-24 Thread vlovich at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102051

Bug ID: 102051
   Summary: [coroutines] ICE in gimplify_var_or_parm_decl, at
gimplify.c:2848
   Product: gcc
   Version: 11.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vlovich at gmail dot com
  Target Milestone: ---

Created attachment 51353
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51353&action=edit
The preprocessed file that causes the ICE

We're adding co-routine support to KJ futures
(https://github.com/capnproto/capnproto/pull/1104). I tried enabling coroutines
on G++ by adjusting async-prelude.h:

-#if __cpp_coroutines && __has_include()
+#if __cpp_impl_coroutine && __has_include()
+// Standardized coroutines detected.
+#include 
+#define KJ_HAS_COROUTINE 1
+#define KJ_COROUTINE_STD_NAMESPACE std
+#elif __cpp_coroutines && __has_include()


This results in an ICE in our test case:

# g++ -std=c++20 -fcoroutines
./c++/src/kj/CMakeFiles/kj-heavy-tests.dir/async-coroutine-test.c++.ii
c++/src/kj/async-coroutine-test.c++: In function ‘kj::Promise
kj::{anonymous}::identity(const char*)’:
c++/src/kj/async-coroutine-test.c++:40:1: internal compiler error: in
gimplify_var_or_parm_decl, at gimplify.c:2840
   40 | }
  | ^
0x1797368 internal_error(char const*, ...)
???:0
0x67f8f9 fancy_abort(char const*, int, char const*)
???:0
0xab710f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xab7130 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xab7a2c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xab81dd gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xab7417 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xab852d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xab86ea gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xab852d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xab723e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xab852d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xab86ea gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
???:0
0xabac7a gimplify_body(tree_node*, bool)
???:0
0xabb022 gimplify_function_tree(tree_node*)
???:0
0x949a87 cgraph_node::analyze()
???:0
0x94cc2d symbol_table::finalize_compilation_unit()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.


I reduced the test case using cvise: https://godbolt.org/z/M5nfEPMKj. This code
works fine against clang's coroutines TS but interestingly clang complains the
reduced test case doesn't compile (https://godbolt.org/z/KjcW94oKM) so maybe
there's just some subtle incompatibility between standard coroutines & the TS
version implemented in clang?

I've attached the full preprocessed file that caused the ICE. Interestingly if
I build against libc++ the ICE doesn't appear so I suspect this may be some
kind of bug in the frontend triggered by some subtlety in the implementation in
libstdc++ OR it's a compilation bug on our end that happens to trigger an ICE.
I don't know coroutines well enough to say.

[Bug c++/102051] [coroutines] ICE in gimplify_var_or_parm_decl, at gimplify.c:2848

2021-08-24 Thread vlovich at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102051

--- Comment #1 from Vitali  ---
Tested via godbolt on 11 & 12.