http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55210



Tobias Burnus <burnus at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

             Status|UNCONFIRMED                 |NEW

   Last reconfirmed|                            |2012-11-05

                 CC|                            |burnus at gcc dot gnu.org

     Ever Confirmed|0                           |1



--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-11-05 
15:32:24 UTC ---

If fails in cpp_interpret_string at

1426                  if (!APPLY_CONVERSION (cvt, base, p - base, &tbuf))



Because "func" is a NULL pointer:



(gdb) p cvt

$13 = {func = 0x0, cd = 0x0, width = 0}





Backtrace:



#0  cpp_interpret_string (pfile=pfile@entry=0x15d9a90,

from=from@entry=0x15da320, count=count@entry=1, to=to@entry=0x7fffffffd1c0, 

    type=<optimized out>) at

/home/tob/projects/gcc-git/gcc/libcpp/charset.c:1426

#1  0x0000000000e71b7d in cpp_interpret_charconst (pfile=0x15d9a90,

token=0x15da318, pchars_seen=0x7fffffffd30c, unsignedp=0x7fffffffd3f0)

    at /home/tob/projects/gcc-git/gcc/libcpp/charset.c:1615

#2  0x0000000000e5fe85 in eval_token (virtual_location=4868, token=0x15da318,

pfile=0x15d9a90)

    at /home/tob/projects/gcc-git/gcc/libcpp/expr.c:964

#3  _cpp_parse_expr (pfile=<optimized out>, is_if=<optimized out>) at

/home/tob/projects/gcc-git/gcc/libcpp/expr.c:1150

#4  0x0000000000e599b4 in do_if (pfile=0x15d9a90) at

/home/tob/projects/gcc-git/gcc/libcpp/directives.c:1953

#5  0x0000000000e5b1b1 in _cpp_handle_directive (pfile=0x15d9a90,

indented=<optimized out>)

    at /home/tob/projects/gcc-git/gcc/libcpp/directives.c:492

#6  0x0000000000e6ea6f in _cpp_scan_out_logical_line

(pfile=pfile@entry=0x15d9a90, macro=macro@entry=0x0)

    at /home/tob/projects/gcc-git/gcc/libcpp/traditional.c:635

#7  0x0000000000e6ef6a in _cpp_read_logical_line_trad (pfile=0x15d9a90) at

/home/tob/projects/gcc-git/gcc/libcpp/traditional.c:306

#8  0x000000000056fa20 in scan_translation_unit_trad (pfile=<optimized out>) at

/home/tob/projects/gcc-git/gcc/gcc/fortran/cpp.c:773







The cvt variable is set via a call to "converter_for_type" with the argument

type=CPP_CHAR. The function contains:

1346      switch (type)

1347        {

1348        default:

1349            return pfile->narrow_cset_desc;

(and also handles CPP_UTF8STRING, CPP_CHAR16, CPP_CHAR32, CPP_WCHAR and

CPP_WSTRING).





The CPP_CHAR is probably generated in lex.c's lex_string





The function narrow_cset_desc should get set via:

  cpp_init_iconv (cpp_reader *pfile)

which has:

  pfile->narrow_cset_desc = init_iconv_desc (pfile, ncset, SOURCE_CHARSET);

where "nset" gets set via:

  const char *ncset = CPP_OPTION (pfile, narrow_charset);







If one calls "cpp" for the file (which matches calling "cc1 -E"), the type is

also CPP_CHAR, but pfile->narrow_cset_desc alias cvt.func is

convert_no_conversion.



 * * *



I wonder whether one should call cpp_init_iconv - as C/C++ does in

../gcc/c-family/c-opts.c's c_common_init:



  /* Set up preprocessor arithmetic.  Must be done after call to

     c_common_nodes_and_builtins for type nodes to be good.  */

  cpp_opts->precision = TYPE_PRECISION (intmax_type_node);

  cpp_opts->char_precision = TYPE_PRECISION (char_type_node);

  cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);

  cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);

  cpp_opts->unsigned_wchar = TYPE_UNSIGNED (wchar_type_node);

  cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN;



  /* This can't happen until after wchar_precision and bytes_big_endian

     are known.  */

  cpp_init_iconv (parse_in);

Reply via email to