>-----Ursprüngliche Nachricht-----
>Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
>Auftrag von James K. Lowden
>Gesendet: Freitag, 27. Jänner 2017 20:08
>An: sqlite-users@mailinglists.sqlite.org
>Betreff: Re: [sqlite] BUG: Illegal initialization in icu.c : sqlite3IcuInit
>
>On Thu, 26 Jan 2017 08:19:02 +0000
>Hick Gunter <h...@scigames.at> wrote:
>
>> On LP_64 architactures, the integer 0 is 32 bits while (void *)0 is
>> 64 bits, which makes more than a bit of a difference. A 64 bit integer
>> 0 would be denoted by 0L.
>
>in C, as you know, integer assignment is subject to integer promotion.
>If the LHS is wider, the RHS is widened to match.  The specification is much 
>more precise, of course, but that's the effect.
>
>There's nothing invalid of ambiguous about:
>
>       long L = '\0';
>
>It is the same as
>
>       long L = 0L;
>
>The same is true for pointers.
>
>--jkl
>

Integer promotion is usually ok between integers of the same signedness.

However, in

        unsigned char uns = 0xff;
        long val = uns;

what should be the (32 Bit size assumed) value of val? Should it be 0x000000ff 
(promotion before conversion) or 0xffffffff (promotion after conversion)? Or 
flagged as "assignment between variables of different signedness"?

Or for example, how often is the loop executed?

        uint16_t count = 0xffff;
        int16_t ii;

        for (ii = 0; II < count, ii++) { ... }


 Integer demotion (i.e. copying a value from a larger size to a smaller size 
integer) should be flagged by the compiler (unless the compiler is clever 
enough to figure out that the value cannot be out of range).

        long val = 0x65;
        char xxx = val;


However

        struct mystruct *ptr1 = '\0';
        struct mystruct *ptr2 = 0;

is "making a pointer from an integer of a different size without a cast" (the 
first on all architectures, the second on LP64 architectures).

Of course this is nitpicking and the examples are trivial, but compilers need 
to guess if the programmer is just being stupid or downright brilliant...

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to