This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, libcpp] Fix thinko in _cpp_remaining_tokens_num_in_context (PR bootstrap/50801)


Dodji Seketeli wrote:

>    cpp_context *context = pfile->context;
>    if (context->tokens_kind == TOKENS_KIND_DIRECT)
> -    return ((LAST (context).token - FIRST (context).token)
> -	    / sizeof (cpp_token));
> +    return (LAST (context).token - FIRST (context).token);
>    else if (context->tokens_kind == TOKENS_KIND_INDIRECT
>  	   || context->tokens_kind == TOKENS_KIND_EXTENDED)
>      return ((LAST (context).ptoken - FIRST (context).ptoken)

B.t.w. isn't the same thinko also present in the "else if" path:

  else if (context->tokens_kind == TOKENS_KIND_INDIRECT
           || context->tokens_kind == TOKENS_KIND_EXTENDED)
    return ((LAST (context).ptoken - FIRST (context).ptoken)
            / sizeof (cpp_token *));

"ptoken" seems to be of type "const cpp_token **", so the pointer
subtraction already divides by sizeof (cpp_token *).

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]