Re: Text search segmentation fault

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: Text search segmentation fault
Дата
Msg-id 877i4eoybi.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: Text search segmentation fault  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Text search segmentation fault
Список pgsql-general
Tom Lane <tgl@sss.pgh.pa.us> writes:

> Gregory Stark <stark@enterprisedb.com> writes:
>> Maybe I'm missing something but I don't understand how this fixes the problem.
>> s is a "char*" so type punning it to an unsigned char * before dereferencing
>> it is really the same as casting it to unsigned char directly
>
> No, it isn't.  If char is signed then you'll get quite different results
> from a high-bit-set byte value, because sign extension will happen
> before the value is reinterpreted as unsigned.

What I wrote is correct. There's no sign extension if you're casting from
signed char to unsigned char since there's no extension.

I really think he should just change all the "unsigned int" into "unsigned
char" and not do the type punning with pointer casts. That's just evil.

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's Slony Replication support!

В списке pgsql-general по дате отправления:

Предыдущее
От: Bill Moran
Дата:
Сообщение: Re: Pet Peeves?
Следующее
От: Daniel Chiaramello
Дата:
Сообщение: Re: chinese parser for text search !