473,943 Members | 2,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementation-defined behaviour

AFAIK the following is implementation-defined behaviour, am I right?:
#include <stdio.h>
int main(void)
{
int n= 0;

printf("%d\n", n++);
return 0;
}
Mar 28 '08 #1
30 1774
Ioannis Vranos wrote:
AFAIK the following is implementation-defined behaviour, am I right?:

#include <stdio.h>

int main(void)
{
int n= 0;
printf("%d\n", n++);
return 0;
}
I don't think so.

Mar 28 '08 #2
santosh wrote:
Ioannis Vranos wrote:
>AFAIK the following is implementation-defined behaviour, am I right?:

#include <stdio.h>

int main(void)
{
int n= 0;
printf("%d\n ", n++);
return 0;
}

I don't think so.
There are similar examples at 2.12 of K&R2.
Two quotes from there:

"printf("%d %d\n", ++n, power(2, n)); /* WRONG */"
"One unhappy situation is typified by the statement

a[i]= i++;"
Mar 28 '08 #3
Ioannis Vranos wrote:
AFAIK the following is implementation-defined behaviour, am I right?:
#include <stdio.h>
int main(void)
{
int n= 0;

printf("%d\n", n++);
return 0;
}
Only by quibbles: the form of "successful termination"
returned to the host environment is implementation-defined,
the actual new-line representation written to stdout in
response to the '\n' is implementation-defined, and things
of that sort.

What aspect do you believe is not Standard-defined?

--
Eric Sosman
es*****@ieee-dot-org.invalid
Mar 28 '08 #4
Eric Sosman wrote:
Ioannis Vranos wrote:
>AFAIK the following is implementation-defined behaviour, am I right?:
#include <stdio.h>
int main(void)
{
int n= 0;

printf("%d\n", n++);
return 0;
}

Only by quibbles: the form of "successful termination"
returned to the host environment is implementation-defined,
the actual new-line representation written to stdout in
response to the '\n' is implementation-defined, and things
of that sort.

What aspect do you believe is not Standard-defined?

I am talking about the implementation-defined behaviour of the printf()
call described at 2.12 of K&R2.

Mar 28 '08 #5
Ioannis Vranos wrote:
santosh wrote:
>Ioannis Vranos wrote:
>>AFAIK the following is implementation-defined behaviour, am I
right?:

#include <stdio.h>

int main(void)
{
int n= 0;
printf("%d\n" , n++);
return 0;
}

I don't think so.

There are similar examples at 2.12 of K&R2.
Two quotes from there:

"printf("%d %d\n", ++n, power(2, n)); /* WRONG */"
"One unhappy situation is typified by the statement

a[i]= i++;"
Well these examples are different from what you have shown above. The
first example above invokes unspecified behaviour while the second one
invokes undefined behaviour. The example in your first post does
neither as far as I can see.

Mar 28 '08 #6
Ioannis Vranos wrote:
Eric Sosman wrote:
>Ioannis Vranos wrote:
>>AFAIK the following is implementation-defined behaviour, am I right?:
#include <stdio.h>
int main(void)
{
int n= 0;

printf("%d\n", n++);
return 0;
}
Only by quibbles: the form of "successful termination"
returned to the host environment is implementation-defined,
the actual new-line representation written to stdout in
response to the '\n' is implementation-defined, and things
of that sort.

What aspect do you believe is not Standard-defined?


I am talking about the implementation-defined behaviour of the printf()
call described at 2.12 of K&R2.
There's nothing wrong with your example, the one you cite is completely
different. If you had tried to use n again in the printf, you would hit UB.

--
Ian Collins.
Mar 28 '08 #7
Ian Collins wrote:
Ioannis Vranos wrote:
>Eric Sosman wrote:
>>Ioannis Vranos wrote:
AFAIK the following is implementation-defined behaviour, am I right?:
#include <stdio.h>
int main(void)
{
int n= 0;

printf("%d\n", n++);
return 0;
}
Only by quibbles: the form of "successful termination"
returned to the host environment is implementation-defined,
the actual new-line representation written to stdout in
response to the '\n' is implementation-defined, and things
of that sort.

What aspect do you believe is not Standard-defined?

I am talking about the implementation-defined behaviour of the printf()
call described at 2.12 of K&R2.
There's nothing wrong with your example, the one you cite is completely
different. If you had tried to use n again in the printf, you would hit UB.

So, printf("%d "%d\n", x++, x++); invokes implementation-defined
behaviour, while printf("%d\n", x++); doesn't invoke
implementation-defined behaviour?

Mar 28 '08 #8
"Ioannis Vranos" <iv*****@nospam .no.spamfreemai l.grwrote in message
news:fs******** ***@ulysses.noc .ntua.gr...
Ian Collins wrote:
>Ioannis Vranos wrote:
>>Eric Sosman wrote:
Ioannis Vranos wrote:
AFAIK the following is implementation-defined behaviour, am I right?:
>
>
#include <stdio.h>
>
>
int main(void)
{
int n= 0;
>
printf("%d\n", n++);
>
>
return 0;
}
Only by quibbles: the form of "successful termination"
returned to the host environment is implementation-defined,
the actual new-line representation written to stdout in
response to the '\n' is implementation-defined, and things
of that sort.

What aspect do you believe is not Standard-defined?

I am talking about the implementation-defined behaviour of the printf()
call described at 2.12 of K&R2.
There's nothing wrong with your example, the one you cite is completely
different. If you had tried to use n again in the printf, you would hit
UB.


So, printf("%d %d\n", x++, x++); invokes implementation-defined
so does:
printf("%d %d\n", x++, x);
behaviour, while printf("%d\n", x++); doesn't invoke
implementation-defined behaviour?
This one does not.

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

Mar 28 '08 #9
Ioannis Vranos wrote:
So, printf("%d "%d\n", x++, x++); invokes implementation-defined
behaviour, while printf("%d\n", x++); doesn't invoke
implementation-defined behaviour?
'printf("%d "%d\n", x++, x++)' invokes _undefined_ behavior. 'printf("%d
"%d\n", x++, x)' also invokes _undefined_ behavior.

'printf("%d\n", x++)' does not invoke undefined behavior.

"Implementa tion-defined behavior" is not immediately relevant to the
nature of your question.

--
Best regards,
Andrey Tarasevich
Mar 28 '08 #10

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

Similar topics

3
1833
by: jenniferyiu | last post by:
IMHO, simply NO. False actually, practically.
9
4677
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
3
1552
by: Eric Chaves | last post by:
Hi fellows, According to the C# language specification (10.5.3), Every virtual method has a "most derived implementation" determined by a 3-step rule. If I invoke the virtual method from a normal variable, everything is ok. However if I call it inside a non-virtual method from the base class, that use's the *this*pointer to actually invoke the virtual method, then those rules doesn't seems to be respected. In fact, the behavior the code below...
6
13728
by: Anders Borum | last post by:
Hello! I accidentally posted this as a reply to another posting. It is a seperate posting - sorry :-) I am programming a cloning service (which is essential to the framework), and am currently using a custom implementation of the ICloneable interface. With this in mind, I am wondering if I would be better off just using the MemberWiseClone method of the inherited base object class.
52
3835
by: lovecreatesbeauty | last post by:
Why the C standard committee doesn't provide a standard implementation including the C compiler and library when the language standard document is published? C works on the abstract model of low level machine. C stands for portability and platform and machine independent. If the C compiler and C standard library are written in C itself, is it possible that one "standard" C compiler plus library is enough? The standard implementation is...
20
6113
by: Luc Kumps | last post by:
(Sorry about the previous post, it got transmitted before it was complete) We try to separate implementation and interface defintions, but we run into a problem. I hope the guru's can solve this, as we seem to lack only a single 'step' to have "full separation"... We have a first project, namespace Ninterface, that contains the interface definitions in class1_interface.cs, like this: namespace Ninterface { public interface IClass1{
7
2090
by: desktop | last post by:
I the C++ standard page 472 it says that an associative container can be constructed like X(i,j,c) where i and j are input iterators to elements. But in the implementation there is no constructor that matches this requirement, the only constructors are: public: // allocation/deallocation _Rb_tree() { }
6
3978
by: Ralph | last post by:
Hi, I was reading effictive C++ and some other books again and they all tell you about hiding implementation details (proxy/pimpl/inheritance) but they never really explain when to use it. I am starting on a new project which is part library so I think it would be good to hide the implementation for the public classes in the library but this seems a lot of overhead to me (both when developing and runtime overhead).
0
2007
by: anto.anish | last post by:
Hi , Since, i did not want to write instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of template methods along with their declarations in the header file. Well, there are also other files in the project, which include this header file as well, which all gets compiled, linked and tested well. #ifndef __ATT_H__
1
2791
by: anto.anish | last post by:
Hi , Since, i did not want to write explicit instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of template methods along with their declarations in the header file. Well, there are also other files in the project, which include this header file as well, which all gets compiled, linked and tested well. #ifndef __ATT_H__
0
10135
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11532
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11122
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
11298
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,...
0
10662
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9864
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8219
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...
2
4510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3511
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.