473,588 Members | 2,452 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Constraint violation - when?

Dear all,

I would like to open another topic to try to clarify a doubt raised on
my previous post today with the subject 'printf("%d%d%d ")'.

Reading through the standard, I cannot find a clear definition of what
is a constraint violation.

Repeating the citation:
3.8
1 constraint
restriction, either syntactic or semantic, by which the exposition
of language elements is to be interpreted

As I understand it, a constraint is any explicit syntax or semantic rule.

Still, i = i++; is not a constraint violation.

Why? The standard clearly says that a variable cannot be modified more
than once within a single sequence point. The aforementioned code
modifies i twice. Isn't it a semantical rule being violated?

P.S. It's incredible how many things I get wrong reading the standard....

--
Pietro Cerutti
Jul 30 '08 #1
12 3367
Pietro Cerutti <gahr_SPAM_gahr _ME_chwrote:
Dear all,

I would like to open another topic to try to clarify a doubt raised on
my previous post today with the subject 'printf("%d%d%d ")'.

Reading through the standard, I cannot find a clear definition of what
is a constraint violation.

Repeating the citation:
3.8
1 constraint
restriction, either syntactic or semantic, by which the
exposition of language elements is to be interpreted

As I understand it, a constraint is any explicit syntax or semantic
rule.

Still, i = i++; is not a constraint violation.

Why? The standard clearly says that a variable cannot be modified more
than once within a single sequence point. The aforementioned code
modifies i twice. Isn't it a semantical rule being violated?

P.S. It's incredible how many things I get wrong reading the
standard....
From n1256.pdf

4. Conformance

1 In this International Standard, ??shall?? is to be interpreted as a
requirement on an implementation or on a program; conversely, ??shall
not?? is to be interpreted as a prohibition.
2 If a ??shall?? or ??shall not?? requirement that appears outside of a
constraint is violated, the behavior is undefined. Undefined behavior
is otherwise indicated in this International Standard by the
words ??undefined behavior?? or by the omission of any explicit
definition of behavior. There is no difference in emphasis among these
three; they all describe ??behavior that is undefined??.

Jul 30 '08 #2
santosh wrote:
Pietro Cerutti <gahr_SPAM_gahr _ME_chwrote:
>Dear all,

I would like to open another topic to try to clarify a doubt raised on
my previous post today with the subject 'printf("%d%d%d ")'.

Reading through the standard, I cannot find a clear definition of what
is a constraint violation.

Repeating the citation:
3.8
1 constraint
restriction, either syntactic or semantic, by which the
exposition of language elements is to be interpreted

As I understand it, a constraint is any explicit syntax or semantic
rule.

Still, i = i++; is not a constraint violation.

Why? The standard clearly says that a variable cannot be modified more
than once within a single sequence point. The aforementioned code
modifies i twice. Isn't it a semantical rule being violated?

P.S. It's incredible how many things I get wrong reading the
standard....

From n1256.pdf

4. Conformance

1 In this International Standard, ??shall?? is to be interpreted as a
requirement on an implementation or on a program; conversely, ??shall
not?? is to be interpreted as a prohibition.
2 If a ??shall?? or ??shall not?? requirement that appears outside of a
constraint is violated, the behavior is undefined. Undefined behavior
is otherwise indicated in this International Standard by the
words ??undefined behavior?? or by the omission of any explicit
definition of behavior. There is no difference in emphasis among these
three; they all describe ??behavior that is undefined??.
Great, thanks. I think I've got it now...

--
Pietro Cerutti
Jul 30 '08 #3
Pietro Cerutti wrote:
Dear all,

I would like to open another topic to try to clarify a doubt raised on
my previous post today with the subject 'printf("%d%d%d ")'.

Reading through the standard, I cannot find a clear definition of what
is a constraint violation.

Repeating the citation:
3.8
1 constraint
restriction, either syntactic or semantic, by which the exposition
of language elements is to be interpreted
I agree that this description is quite elliptic; I've never been able to
attach any clear meaning to the part after the second comma. However,
all is not lost --
As I understand it, a constraint is any explicit syntax or semantic rule.
Whatever it is that they meant to say in the definition above, it
appears, from the way the standard uses the term, that syntax rules are
distinct from syntactic constraints, and that semantic rules are
distinct from semantic constraints.

All you have to do to identify a constraint is to look at the title of
the section where you found it. If that title is "constraint s", then
it's a constraint; otherwise it's something else. Exception:
5.1.2.2.1p2, 6.10p2.

Lawrence Jones: wouldn't it be more consistent if 5.1.2.2.1p2 and 6.10p2
were not exceptions to this pattern?
Jul 30 '08 #4
Pietro Cerutti <gahr_SPAM_gahr _ME_chwrites:

<snip>
Still, i = i++; is not a constraint violation.

Why?
To add a little more... It is not a constraint violation because
constraints must be checked by the implementation and violations of
this rule (no multiple updates between sequence points) are hard to
diagnose in general (in fact it is not possible to detect this in
every case).

--
Ben.
Jul 30 '08 #5
Ben Bacarisse wrote:
Pietro Cerutti <gahr_SPAM_gahr _ME_chwrites:

<snip>
>Still, i = i++; is not a constraint violation.

Why?

To add a little more... It is not a constraint violation because
constraints must be checked by the implementation and violations of
this rule (no multiple updates between sequence points) are hard to
diagnose in general (in fact it is not possible to detect this in
every case).
Thanks for this point Ben. Then it's more about commodity to check than
about exact rules of the language.

--
Pietro Cerutti
Jul 30 '08 #6
James Kuyper wrote:
Pietro Cerutti wrote:
>Dear all,

I would like to open another topic to try to clarify a doubt raised on
my previous post today with the subject 'printf("%d%d%d ")'.

Reading through the standard, I cannot find a clear definition of what
is a constraint violation.
[snip]
All you have to do to identify a constraint is to look at the title of
the section where you found it. If that title is "constraint s", then
it's a constraint; otherwise it's something else. Exception:
5.1.2.2.1p2, 6.10p2.
This is a very good and practical hint! Thanks!
--
Pietro Cerutti
Jul 30 '08 #7
Pietro Cerutti <gahr_SPAM_gahr _ME_chwrites:
Ben Bacarisse wrote:
>Pietro Cerutti <gahr_SPAM_gahr _ME_chwrites:
<snip>
>>Still, i = i++; is not a constraint violation.

Why?
To add a little more... It is not a constraint violation because
constraints must be checked by the implementation and violations of
this rule (no multiple updates between sequence points) are hard to
diagnose in general (in fact it is not possible to detect this in
every case).

Thanks for this point Ben. Then it's more about commodity to check
than about exact rules of the language.
It's more about the fact that the standard's definition of
"constraint " in C99 3.8 is too vague.

If you think of a "constraint " as "any requirement that's in a section
marked 'Constraints'", there's little or no ambiguity.

And yes, the set of requirements that are "constraint s" was carefully
chosen to allow them to be reliable checked by the compiler. If it
were practical to diagnose "i = i++;" at compile time, it probably
would have been made a constraint.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 30 '08 #8
James Kuyper <ja*********@ve rizon.netwrites :
[...]
All you have to do to identify a constraint is to look at the title of
the section where you found it. If that title is "constraint s", then
it's a constraint; otherwise it's something else. Exception:
5.1.2.2.1p2, 6.10p2.

Lawrence Jones: wouldn't it be more consistent if 5.1.2.2.1p2 and
6.10p2 were not exceptions to this pattern?
In 5.1.2.2.1p2:

If they are declared, the parameters to the main function shall
obey the following constraints:
...

the word "constraint s" is being used in a manner that's consistent
with the vague definition in 3.8, but not with the general usage of
the term "constraint " as a requirement whose violation can be
diagnosed at compile time.

The use of term "constraint s" in 6.10p2 is also rather odd. Something
that violates the listed "constraint s" isn't necessarily a diagnosable
error; it's just not a preprocessing directive.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 30 '08 #9
Keith Thompson wrote:
James Kuyper <ja*********@ve rizon.netwrites :
[...]
All you have to do to identify a constraint is to look at the title of
the section where you found it. If that title is "constraint s", then
it's a constraint; otherwise it's something else. Exception:
5.1.2.2.1p2, 6.10p2.

Lawrence Jones: wouldn't it be more consistent if 5.1.2.2.1p2 and
6.10p2 were not exceptions to this pattern?
Note: I got an autormated reply that he's on vacation until 8/11
>
In 5.1.2.2.1p2:

If they are declared, the parameters to the main function shall
obey the following constraints:
...

the word "constraint s" is being used in a manner that's consistent
with the vague definition in 3.8, but not with the general usage of
the term "constraint " as a requirement whose violation can be
diagnosed at compile time.
Yes, those are run-time constraints on the implementation, rather than
compile-time constraints on the program.
The use of term "constraint s" in 6.10p2 is also rather odd. Something
that violates the listed "constraint s" isn't necessarily a diagnosable
error; it's just not a preprocessing directive.
You're right: I just did a quick search for "constraint ". I thought
those were just a couple of inconsistencies that slipped past the
editor. If I'd thought about it a little longer, I'd have realize why
these two were handled differently than the other "contraint"
sections.
Jul 30 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5171
by: Sudip Chakraborty | last post by:
Is there a way to see constraint validation errors while loading xml into a DataSet ? I'm interested in the line number in the xml file which is causing the error. I've enclosed the relevant stack trace below. at System.Data.DataSet.FailedEnableConstraints() at System.Data.DataSet.EnableConstraints() at System.Data.DataSet.set_EnforceConstraints(Boolean value)
8
7630
by: Ollie Riches | last post by:
I am trying to access an AD from asp.net, I am getting the 'famous' "The specified domain either does not exist or could not be contacted" exception with a HR = 0x08007054b the code (C# .Net) is as follows: DirectoryEntry rootEntry = new DirectoryEntry("LDAP://RootDSE"); string contextPath = rootEntry.Properties.Value.ToString(); rootEntry.Dispose();
2
6536
by: D. Dante Lorenso | last post by:
I'm trying to build a table that will store a history of records by enumerating the records. I want the newest record to always be number ZERO, so I created a trigger on my table to handle the assignment of version numbers: CREATE TRIGGER "trg_audio_file_insert" BEFORE INSERT ON "public"."audio_file" FOR EACH ROW EXECUTE PROCEDURE "public"."trg_audio_file_insert"(); My trigger function looks like this...
2
1814
by: Peter Gebauer | last post by:
Hello. This section works fine: CREATE TABLE torder ( id INT8 NOT NULL PRIMARY KEY ); CREATE TABLE torder_row ( id INT8 NOT NULL PRIMARY KEY,
1
2665
by: Luqman | last post by:
I have created a form using single Table which has customerId and companyName field, using Typed Dataset. Now, if I click on Delete Button of Binding Navigator, the Customer Record is deleted from Dataset, however when I click on Save Button of Binding Navigator, Oracle raises Constraint violation Error, child record found." Why can't VB.Net check the child record / constraint violation when I clicked on Delete Button, any idea please...
3
1808
by: Richard Weeks | last post by:
My question, stated as simply as possible, is: must a constraint violation, as defined by the standard, cause compilation to halt? I believe that in the presence of a constraint violation, at least one diagnostic is required, which, at the discretion of the compiler writer, may be either an "error" or a "warning." Generally however, an error halts compilation and a warning does not. This would seem to imply that it is up to the compiler...
2
2518
by: Kenneth Koenraadt | last post by:
Hi Wing, The utility Oracle offers for that is *check constraints*. For instance : ALTER TABLE Demerit ADD CONSTRAINT a1 CHECK (points between 1 and 6); ALTER TABLE Demerit ADD CONSTRAINT a2 CHECK (dem_code <= 20 or dem_code 20 and points <=3);
15
8555
by: Frank Swarbrick | last post by:
I have the following three tables DROP TABLE CALLTRAK.SERVICE_CODES @ CREATE TABLE CALLTRAK.SERVICE_CODES ( CODE CHAR(1) NOT NULL , CONSTRAINT SERVICE_CODES_PK PRIMARY KEY (CODE) , DESCRIPTION VARCHAR(50) NOT NULL )
2
15060
by: rorajoey | last post by:
Violation of UNIQUE KEY constraint 'IX_surveyQuestions'. Cannot insert duplicate key in object 'dbo.surveyQuestions'. This might seem like a simple matter of trying to insert a row with ID=20 when there's already one with that ID, but the problem is a bit more complicated. The table is supposed to auto-increment the value for the primary key when a new record is inserted. But no matter what I do, I can't seem to insert more than one record...
0
7862
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5729
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1459
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1196
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.