Hey,
It was mentioned elsewhere that printf("%d", INT_MAX);
is implementation-defined. Why? Is it because INT_MAX
value is implementation-defined so output depends
on implementation, or is it something more subtle so
that output of the following is also implementation-defined:
if (INT_MAX == 65535)
printf("%d", INT_MAX);
else
printf("%d", 65535);
Thanks,
Yevgen
Mar 14 '07
26 6871
Flash Gordon wrote:
>
Keith Thompson wrote, On 16/03/07 21:50:
.... snip ...
>
>I feel reasonably confident that the comittee did not intend the concept of "strictly conforming" to be quite *that* useless.
However:
int main(void) { while (1); }
It even still leaves us something to discuss. I prefer
int main(void)
{
for (;;)
continue;
}
You both omitted the final "return 0" for C90. :-)
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
--
Posted via a free Usenet account from http://www.teranews.com
CBFalconer <cb********@yah oo.comwrites:
Flash Gordon wrote:
>Keith Thompson wrote, On 16/03/07 21:50:
... snip ...
>>
>>I feel reasonably confident that the comittee did not intend the concept of "strictly conforming" to be quite *that* useless.
However:
int main(void) { while (1); }
It even still leaves us something to discuss. I prefer int main(void) { for (;;) continue; }
You both omitted the final "return 0" for C90. :-)
Which could cause problems as soon as control reaches the closing
brace. Wait here and let me know what happens.
--
Keith Thompson (The_Other_Keit h) 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"
Keith Thompson wrote On 03/16/07 17:50,:
Eric Sosman <Er*********@su n.comwrites:
>>Flash Gordon wrote On 03/16/07 14:48,:
>>>CBFalconer wrote, On 15/03/07 21:52:
[...]
>>>>I don't think a strictly conforming *program* exists,
<pedantic> What about: int main(void) { return 0; } </pedantic>
Sorry: It returns an implementation-defined form of "success" to the host environment. Something that goes from the program to the environment is surely "output," hence the program produces implementation-defined output.
;-)
I feel reasonably confident that the comittee did not intend the
concept of "strictly conforming" to be quite *that* useless.
However:
int main(void) { while (1); }
Strictly conforming, I believe. The problem is to find
an implementation that can execute it correctly.
-- Er*********@sun .com
Eric Sosman wrote:
>
Keith Thompson wrote On 03/16/07 17:50,:
int main(void) { while (1); }
Strictly conforming, I believe. The problem is to find
an implementation that can execute it correctly.
Here's another one that's strictly conforming
and which some M$ compilers won't compile:
int main(void)
{
int zero = 0;
return zero && (1 / 0);
}
--
pete
pete wrote:
Eric Sosman wrote:
Keith Thompson wrote On 03/16/07 17:50,:
int main(void) { while (1); }
Strictly conforming, I believe. The problem is to find
an implementation that can execute it correctly.
Here's another one that's strictly conforming
and which some M$ compilers won't compile:
int main(void)
{
int zero = 0;
return zero && (1 / 0);
}
Here's another one that's strictly conforming and which some G¢¢
(seriously, enough with the "M$") compilers won't compile:
int f(void)
{
int result = 1 / 0;
return result;
}
int main(void)
{
return 0 && f();
}
Harald van Dijk wrote:
pete wrote:
>Eric Sosman wrote:
>>Keith Thompson wrote On 03/16/07 17:50,: int main(void) { while (1); } Strictly conforming, I believe. The problem is to find an implementation that can execute it correctly.
Here's another one that's strictly conforming and which some M$ compilers won't compile:
int main(void) { int zero = 0;
return zero && (1 / 0); }
Here's another one that's strictly conforming and which some G¢¢
(seriously, enough with the "M$") compilers won't compile:
int f(void)
{
int result = 1 / 0;
return result;
}
int main(void)
{
return 0 && f();
}
My DJGPP (GNU C 3.1) issues a warning..
d0.c: In function `f':
d0.c:3: warning: division by zero
...and compiles. Running the program gives no error so I'll assume f()
doesn't get called.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Joe Wright wrote:
Harald van Dijk wrote:
pete wrote:
Eric Sosman wrote: Keith Thompson wrote On 03/16/07 17:50,: int main(void) { while (1); } Strictly conforming, I believe. The problem is to find an implementation that can execute it correctly.
Here's another one that's strictly conforming
and which some M$ compilers won't compile:
int main(void)
{
int zero = 0;
return zero && (1 / 0);
}
Here's another one that's strictly conforming and which some G¢¢
(seriously, enough with the "M$") compilers won't compile:
int f(void)
{
int result = 1 / 0;
return result;
}
int main(void)
{
return 0 && f();
}
My DJGPP (GNU C 3.1) issues a warning..
d0.c: In function `f':
d0.c:3: warning: division by zero
..and compiles. Running the program gives no error so I'll assume f()
doesn't get called.
Try compiling with the -ansi and -pedantic-errors options (with which
GCC aims to conform to C90 as strictly as allowed). If it still works
then, you're not using a version of GCC affected by that particular
bug. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sugaray |
last post by:
does the expression int a=printf("%d\n",a); implementation dependent ?
I supposed it would produced the result 2, but i got 4206596 (result
may vary on your machine), i wonder if the value produced was a memory
address and anything special with this expression ?
|
by: infobahn |
last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
|
by: baumann |
last post by:
hi all,
printf("%c",b) doesn't work properly.
#include <stdio.h>
int a , b;
char d, e;
char * p;
float f;
int main(int argc, char* argv)
{
|
by: geek |
last post by:
Hi all,
Why does a printf("%d") statement prints this as output and when I do
printf("%c") it doesn't print anything.
-13361016
Any help would be appreciated.
Thanks,
|
by: v4vijayakumar |
last post by:
why the following statement dumps the core(Segmentation fault)?
printf("%s\n", __FILE__);
| |
by: Zero |
last post by:
Hi everybody,
i want to write a small program, which shows me the biggest and
smallest number in dependance of the data type.
For int the command could be:
printf("\n%20s\t%7u\t%13i\t%13i","signed int",sizeof(signed
int),INT_MIN,INT_MAX);
|
by: lovecreatesbeauty |
last post by:
Is parameter type conversion required for the 2nd argument on
printf("%p", (void *)&i); ?
But one would never call memcpy like:
memcpy((void *)pi, (void *)pj, sizeof *pj);
/*memcpy((void *)pi, (void *)pj, sizeof *pi);*/ /*size of what?*/
By the way, will the 3rd argument of memcpy follow the size of the 1st
or the 2nd argument? If it follows the size of the 1st argument,
unwanted data in the memory area pointed by the 2nd parameter...
|
by: Rajesh S R |
last post by:
printf("%hhd",89);/*Assume char has 8 bits and is signed*/
Is it valid?
I know that it has been discussed in comp.std.c.
http://groups.google.co.in/group/comp.std.c/browse_thread/thread/a656169cb5941cbf/?hl=en#
But I want to know what was the conclusion that has been reached. It
is unusually long with 146 posts. Therefore it is hard to follow the
|
by: candy_init |
last post by:
Hi all,
I just came across the following program:
#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 0;
|
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...
|
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...
| |
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |