Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ike Naar <ike@iceland.freeshell.org> |
|---|---|
| Newsgroups | comp.std.c |
| Subject | Re: Second draft, "Safe arrays and pointers for C" |
| Date | 2012-09-03 16:39 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrn3vfsk49n9c.74s.ike@iceland.freeshell.org> (permalink) |
| References | <503FC37F.8050701@animats.com> <k1rd60$f4s$1@speranza.aioe.org> <50415632.6060606@animats.com> <aahtcmFsb9U1@mid.dfncis.de> <k22k3d$fa$1@news.albasani.net> |
On 2012-09-03, BGB <cr88192@hotmail.com> wrote:
> On 9/2/2012 3:20 PM, Hans-Bernhard Br?ker wrote:
>> On 01.09.2012 02:26, John Nagle wrote:
>>
>>> Not really. The main use case for unions is for data read
>>> in from an external source, often a network.
>>
>> No, it's not, because the vast majority of usages of unions for that
>> purpose would automatically cause undefined behaviour.
>>
>
> yeah, and also most cases I have seen unions used for have little to do
> with network data.
>
>
>>> Tightening down the screws further on that would alienate too many C
>>> programmers. Consider the common idiom
>>>
>>> const char* msg[] =
>>> {"First message", "second message", "third message", 0 }
>>
>
> (ironically, the above will probably only work without issue in C++, and
> in C will usually generate a message something like "warning: int to
> pointer conversion without a cast" or similar... this means the array
> needs to be terminated with either NULL or "((void *)0)" or "((char
> *)0)" or similar to avoid the compiler complaining about it).
In C, 0 is perfectly fine as a char* (it's a null pointer constant).
Have you really seen warnings for this?
Back to comp.std.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Second draft, "Safe arrays and pointers for C" John Nagle <nagle@animats.com> - 2012-08-30 12:48 -0700
Re: Second draft, "Safe arrays and pointers for C" pacman@kosh.dhis.org (Alan Curry) - 2012-08-31 22:17 +0000
Re: Second draft, "Safe arrays and pointers for C" John Nagle <nagle@animats.com> - 2012-08-31 17:26 -0700
Re: Second draft, "Safe arrays and pointers for C" Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2012-09-02 22:20 +0200
Re: Second draft, "Safe arrays and pointers for C" BGB <cr88192@hotmail.com> - 2012-09-03 10:55 -0500
Re: Second draft, "Safe arrays and pointers for C" Ike Naar <ike@iceland.freeshell.org> - 2012-09-03 16:39 +0000
Re: Second draft, "Safe arrays and pointers for C" BGB <cr88192@hotmail.com> - 2012-09-03 13:18 -0500
Re: Second draft, "Safe arrays and pointers for C" Jens Gustedt <jens.gustedt@loria.fr> - 2012-09-02 10:52 +0200
Re: Second draft, "Safe arrays and pointers for C" Per <per.mathisen@gmail.com> - 2012-09-28 06:49 -0700
Re: Second draft, "Safe arrays and pointers for C" John Nagle <nagle@animats.com> - 2012-09-28 11:36 -0700
Re: Second draft, "Safe arrays and pointers for C" Per <per.mathisen@gmail.com> - 2012-10-01 09:38 -0700
Re: Second draft, "Safe arrays and pointers for C" John Nagle <nagle@animats.com> - 2012-10-01 11:38 -0700
Re: Second draft, "Safe arrays and pointers for C" Shao Miller <sha0.miller@gmail.com> - 2012-12-17 09:11 -0500
Re: Second draft, "Safe arrays and pointers for C" Keith Thompson <kst-u@mib.org> - 2012-12-17 10:18 -0800
Re: Second draft, "Safe arrays and pointers for C" Shao Miller <sha0.miller@gmail.com> - 2012-12-17 18:24 -0500
Re: Second draft, "Safe arrays and pointers for C" Shao Miller <sha0.miller@gmail.com> - 2012-12-17 18:32 -0500
Re: Second draft, "Safe arrays and pointers for C" Keith Thompson <kst-u@mib.org> - 2012-12-17 15:44 -0800
csiph-web