wtf is n1570?

P

pete

In another forum I'm arguing against an outlandish claim: that
modifying a variable marked as const in a C source file generates a
run-time error because it is (as is claimed) undefined behavior.

The other guy's reference is n1570, ( http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
) section 6.7.3.

That section does indeed seem to support his argument. Horrifying!

So I ask you, sisters and brothers, what IS this n1570? And does it
have any force of law?

Thanks!
 
E

Eric Sosman

In another forum I'm arguing against an outlandish claim: that
modifying a variable marked as const in a C source file generates a
run-time error because it is (as is claimed) undefined behavior.

It is in fact undefined behavior. It does not necessarily produce
a run-time error, though: "undefined" means "not defined," so anything
at all may (in principle) occur. You might get a crash, you might see
the sudden inversion of every sign bit in the program, you might see
something you sort of expected. It used to be said that UB could make
demons fly out of your nose; from the Standard's point of view the
nasal demons are entirely plausible, although the engineering challenges
are somewhat daunting.
The other guy's reference is n1570, ( http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
) section 6.7.3.

That section does indeed seem to support his argument. Horrifying!

So I ask you, sisters and brothers, what IS this n1570? And does it
have any force of law?

There's a really informative web site that has a lot of information
about this and many other topics. Can't recall the name, exactly --
goggle.com? giggle.com? When I'm not so busy, I'll google it.

As for "force of law," well, no. IANAL, but to the best of my
knowledge you cannot be fined, jailed, or summarily executed for
disbelieving a draft International Standard, nor even the adopted
International Standards that contain equivalent language. I suppose
that if you contracted with someone to do "C programming" and your
work product did not follow "accepted professional norms" you might
be open to a civil lawsuit, but I don't think it rises to the level
of an actual felony. So, yeah: In my non-lawyerly opinion, trying
to alter a const-qualified object is every bit as legal as trying to
dereference a NULL pointer. Go for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top