What's the best way to minimize the need of run time checks?

Grant Edwards grant.b.edwards at gmail.com
Mon Aug 29 10:00:30 EDT 2016


On 2016-08-29, Chris Angelico <rosuav at gmail.com> wrote:
> On Mon, Aug 29, 2016 at 10:13 PM, BartC <bc at freeuk.com> wrote:
>> In C, you can write this:
>>
>>  int x;
>>
>>  x = 5;
>>  x = "hello";
>>
>> With certain compilers (eg. gcc) you only get a warning. (And since
>> I don't show warnings to avoid inundation, that seems to compile
>> fine for me!)

If you're ignoring compiler warnings, you're asking for problems and
deserve whatever trouble you get.

> That's because strings, in C, are really pointers-to-char, and for
> hysterical raisins, pointers can be assigned to integers with just a
> warning. (Good code should have an explicit cast here.)
>
> You probably should have warnings enabled.

IMO, when doing doing development with GCC, -Wall -Werror is the
absolute minimum standard.

-- 
Grant Edwards               grant.b.edwards        Yow! Will it improve my
                                  at               CASH FLOW?
                              gmail.com            




More information about the Python-list mailing list