[Bug preprocessor/96935] ICE in subspan, at input.h:69

2020-09-04 Thread jan.smets at nokia dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96935

--- Comment #3 from Jan Smets  ---
A bisect resulted in this commit :

commit 0d48e8779c6a9ac88f5efd1b4a2d40f43ef75faf
Author: David Malcolm 
Date:   Fri Oct 5 19:02:17 2018 +

Support string locations for C++ in -Wformat (PR c++/56856)

-Wformat in the C++ FE doesn't work as well as it could:
(a) it doesn't report precise locations within the string literal, and
(b) it doesn't underline arguments for those arguments
!CAN_HAVE_LOCATION_P,
despite having location wrapper nodes.



Your suggestion doesn't trigger it for me.
I'v  built GCC with -g -O0 , but the standard provided backtrace didn't include
function call arguments.

A printf confirms your suspicion about start.column == 0 
 => start.column=0 literal_length=1

[Bug preprocessor/96935] ICE in subspan, at input.h:69

2020-09-04 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96935

--- Comment #2 from Richard Biener  ---
Guess the error is simply that we fall back to no columns and thus start.column
== 0 and we do

  char_span literal = line.subspan (start.column - 1, literal_length);

which means input.c:1467 should check whether start.column is >= 1

Might also trigger with

printf ("\
..")

who knows.

Your backtrace doesn't contain function argument values to verify.  Maybe you
can
build GCC with -O0 once and check?

[Bug preprocessor/96935] ICE in subspan, at input.h:69

2020-09-04 Thread jan.smets at nokia dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96935

--- Comment #1 from Jan Smets  ---
Proper backtrace (10.2)

x.cpp: In function ‘void a()’:
x.cpp:3: internal compiler error: in subspan, at input.h:69
3 | #define DB_PRINTF(str, fmt, args...) db_printf(indent_len, 50, fmt,
str, ##args)
  |
x.cpp:7: note: in expansion of macro ‘DB_PRINTF’
7 |   DB_PRINTF("", "%llu", 0);
  |
0x168ee7b char_span::subspan(int, int) const
/jasmets/git/tools/gcc/gcc/input.h:69
0x168ee7b get_substring_ranges_for_loc
/jasmets/git/tools/gcc/gcc/input.c:1467
0x168ee7b get_location_within_string(cpp_reader*, string_concat_db*, unsigned
int, cpp_ttype, int, int, int, unsigned int*)
/jasmets/git/tools/gcc/gcc/input.c:1553
0x8fad84 c_get_substring_location(substring_loc const&, unsigned int*)
/jasmets/git/tools/gcc/gcc/c-family/c-common.c:903
0x92e3ad get_corrected_substring
/jasmets/git/tools/gcc/gcc/c-family/c-format.c:4505
0x92e3ad format_type_warning
/jasmets/git/tools/gcc/gcc/c-family/c-format.c:4721
0x93142b check_format_types
/jasmets/git/tools/gcc/gcc/c-family/c-format.c:4266
0x93142b argument_parser::check_argument_type(format_char_info const*,
length_modifier const&, tree_node*&, char const*&, bool, unsigned long&,
tree_node*&, int, char const*, char const*, unsigned int, char)
/jasmets/git/tools/gcc/gcc/c-family/c-format.c:2859
0x9332e0 check_format_info_main
/jasmets/git/tools/gcc/gcc/c-family/c-format.c:3998
0x9332e0 check_format_arg
/jasmets/git/tools/gcc/gcc/c-family/c-format.c:1821
0x92f3a2 check_format_info
/jasmets/git/tools/gcc/gcc/c-family/c-format.c:1543
0x92f3a2 check_function_format(tree_node const*, tree_node*, int, tree_node**,
vec*)
/jasmets/git/tools/gcc/gcc/c-family/c-format.c:1197
0x922f09 check_function_arguments(unsigned int, tree_node const*, tree_node
const*, int, tree_node**, vec*)
/jasmets/git/tools/gcc/gcc/c-family/c-common.c:5730
0x77d86f build_over_call
/jasmets/git/tools/gcc/gcc/cp/call.c:8901
0x77f2ea build_new_function_call(tree_node*, vec**, int)
/jasmets/git/tools/gcc/gcc/cp/call.c:4613
0x8baac6 finish_call_expr(tree_node*, vec**, bool,
bool, int)
/jasmets/git/tools/gcc/gcc/cp/semantics.c:2672
0x864abf cp_parser_postfix_expression
/jasmets/git/tools/gcc/gcc/cp/parser.c:7468
0x84d261 cp_parser_unary_expression
/jasmets/git/tools/gcc/gcc/cp/parser.c:8563
0x846d11 cp_parser_cast_expression
/jasmets/git/tools/gcc/gcc/cp/parser.c:9459
0x8473e1 cp_parser_binary_expression
/jasmets/git/tools/gcc/gcc/cp/parser.c:9562