By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,591 Members | 650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,591 IT Pros & Developers. It's quick & easy.

struct tm

P: n/a
Under c90, not c99, where is the behavior
outlined for memset zeroing such an
object of this struct type? I know
under c99 you have the possibility
of creating a trap representation or
raising an implementation defined signal
but what about c90?

--
aegis

Jun 21 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
aegis <ae***@mad.scientist.comwrote:
Under c90, not c99, where is the behavior
outlined for memset zeroing such an
object of this struct type? I know
under c99 you have the possibility
of creating a trap representation or
raising an implementation defined signal
but what about c90?
Note 122 (in the definition of memcmp()) refers to the memset()ing of
struct objects as if it were no problem, and I can find no reason to
suspect otherwise. Therefore, I assume that memset()ing the alignment
and padding bytes in a struct has no impact on the struct's validity
(after all, they are otherwise indeterminate anyway); and that doing so
to any declared struct members is as valid as if they had been normal
objects instead of struct members. So memset()ing unsigned chars struct
members is certainly valid, and memset()ing float struct members only
depending on the floating point model the implementation uses.

Richard
Jun 21 '07 #2

P: n/a
aegis said:
Under c90, not c99, where is the behavior
outlined for memset zeroing such an
object of this struct type?
Everything in it is an int, so you're in the clear. It isn't actually
possible AFAIK to prove from C90 that memsetting (to 0) an aggregate
object containing only integral types will give each of them the value
0, but IIRC according to ISO there are *no* implementations where it
doesn't. I'd give references if I had them. Perhaps someone from ISO
can clarify.
I know under c99 you have the possibility
of creating a trap representation or
raising an implementation defined signal
I don't think so, actually - not for 0.
but what about c90?
I consider myself a rather conservative C programmer, and I regularly
blast an entire memset's-worth of 0s right through my integer-only
aggregate data structures. Not terribly often, though - and, to be
precise, not all that regularly either. But sometimes, anyway. What
*is* the word? Ah! Fearlessly. I fearlessly use memset to 'zero out'
integer-only aggregate data structures. Despite the fact that I haven't
a clue what platforms my code will be run on.

Of course, if there are pointers or floaty-pointy thingies around,
that's a different matter.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 21 '07 #3

P: n/a
Richard Heathfield wrote On 06/21/07 06:43,:
aegis said:

>>Under c90, not c99, where is the behavior
outlined for memset zeroing such an
object of this struct type?


Everything in it is an int, so you're in the clear. [...]
Nitpick: Everything *required* to be in it is an int.
The Standard allows an implementation's struct tm to have
elements other than those listed, and the types of any
extra elements could be whatever the implementation liked.

Personally, I'd just initialize at declaration:

struct tm when = { 0 };

If you need to re-clear it after using it (why?), memset
is very likely safe. For freedom from all possible worry:

static const struct tm zero = { 0 };
struct tm when;
...
when = zero; /* instead of memset */
... fill it in and use it ...
when = zero;
... play it again, Sam ...

--
Er*********@sun.com
Jun 21 '07 #4

P: n/a
aegis wrote:
>
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99 you
have the possibility of creating a trap representation or raising
an implementation defined signal but what about c90?
Totally incomprehensible without proper quoting. What struct
type? What object? See the reference in my sig. below.

--
If you want to post a followup via groups.google.com, ensure
you quote enough for the article to make sense. Google is only
an interface to Usenet; it's not Usenet itself. Don't assume
your readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell.org/google/>

--
Posted via a free Usenet account from http://www.teranews.com

Jun 21 '07 #5

P: n/a
"CBFalconer" writes:
aegis wrote:
>>
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99 you
have the possibility of creating a trap representation or raising
an implementation defined signal but what about c90?

Totally incomprehensible without proper quoting. What struct
type? What object? See the reference in my sig. below.
I agree that the post could have used a few more words. But he used legal
buzzwords and I got at least some meaning out of it. See the link.

http://www.dinkum.com/manuals/?manua...page=time.html
Jun 21 '07 #6

P: n/a
CBFalconer said:
aegis wrote:
>>
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99 you
have the possibility of creating a trap representation or raising
an implementation defined signal but what about c90?

Totally incomprehensible without proper quoting.
Quoting of what, Chuck? He's the OP!

What is happening to you?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 21 '07 #7

P: n/a
Richard Heathfield wrote:
CBFalconer said:
>aegis wrote:
>>>
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99
you have the possibility of creating a trap representation or
raising an implementation defined signal but what about c90?

Totally incomprehensible without proper quoting.

Quoting of what, Chuck? He's the OP!

What is happening to you?
I virtually never look at the subject. I suspect he constructed a
new thread out of a reply to something else.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 22 '07 #8

P: n/a
CBFalconer <cb********@yahoo.comwrites:
Richard Heathfield wrote:
>CBFalconer said:
>>aegis wrote:
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99
you have the possibility of creating a trap representation or
raising an implementation defined signal but what about c90?

Totally incomprehensible without proper quoting.

Quoting of what, Chuck? He's the OP!

What is happening to you?

I virtually never look at the subject. I suspect he constructed a
new thread out of a reply to something else.
That doesn't appear to be the case. If there's insufficient context,
I suggest that you *should* look at the subject before jumping to
conclusions.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 22 '07 #9

P: n/a
Keith Thompson wrote, On 22/06/07 03:53:
CBFalconer <cb********@yahoo.comwrites:
>Richard Heathfield wrote:
>>CBFalconer said:
aegis wrote:
Under c90, not c99, where is the behavior outlined for memset
zeroing such an object of this struct type? I know under c99
you have the possibility of creating a trap representation or
raising an implementation defined signal but what about c90?
Totally incomprehensible without proper quoting.
Quoting of what, Chuck? He's the OP!

What is happening to you?
I virtually never look at the subject. I suspect he constructed a
new thread out of a reply to something else.

That doesn't appear to be the case.
I just checked and there were no references headers, so it definitely
was not the case.
If there's insufficient context,
I suggest that you *should* look at the subject before jumping to
conclusions.
Chuck, you should definitely check before claiming someone should quote
context. Complaining at the OP for not putting all of the information in
the message would be valid, but that is not the complaint made.
--
Flash Gordon
Jun 23 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.