473,324 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

number of semicolons

Hi group,

is the below valid?

int main(void)
{
int i = 4;;;;;;;;
}

It compiles cleanly with GCC -Wall.

I don't see any reason for that, any clarification is welcome!

Thanks,

--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Jan 24 '08 #1
4 1275

"Pietro Cerutti" <gahr_AT_gahr_DOT_ch_DO_NOT_SPAMwrote in message
news:ec***************************@news.hispeed.ch ...
Hi group,

is the below valid?

int main(void)
{
int i = 4;;;;;;;;
}

It compiles cleanly with GCC -Wall.

I don't see any reason for that, any clarification is welcome!
The null statement is allowed.

It means you can do things like

/* execute foo() until it return a zero */
while( foo() );

instead of having to write

while( foo() )
continue;

Obviously your example was pointless, but it would be harder to forbid it
than to allow it.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jan 24 '08 #2
Malcolm McLean wrote:
>
"Pietro Cerutti" <gahr_AT_gahr_DOT_ch_DO_NOT_SPAMwrote in message
news:ec***************************@news.hispeed.ch ...
>Hi group,

is the below valid?

int main(void)
{
int i = 4;;;;;;;;
}

It compiles cleanly with GCC -Wall.

I don't see any reason for that, any clarification is welcome!
The null statement is allowed.

It means you can do things like

/* execute foo() until it return a zero */
while( foo() );

instead of having to write

while( foo() )
continue;

Obviously your example was pointless, but it would be harder to forbid
it than to allow it.
Obvious... my example (which comes from a typo I did) was so pointless
that I didn't see it as a sequence of null operations...

Thanks and sorry for the noise...
--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Jan 24 '08 #3
On Jan 24, 4:00*am, Pietro Cerutti <gahr_AT_gahr_DOT_ch_DO_NOT_SPAM>
wrote:
Malcolm McLean wrote:
"Pietro Cerutti" <gahr_AT_gahr_DOT_ch_DO_NOT_SPAMwrote in message
news:ec***************************@news.hispeed.ch ...
Hi group,
is the below valid?
int main(void)
{
* int i = 4;;;;;;;;
}
It compiles cleanly with GCC -Wall.
I don't see any reason for that, any clarification is welcome!
The null statement is allowed.
It means you can do things like
/* execute foo() until it return a zero */
while( foo() );
instead of having to write
while( foo() )
* continue;
Obviously your example was pointless, but it would be harder to forbid
it than to allow it.

Obvious... my example (which comes from a typo I did) was so pointless
that I didn't see it as a sequence of null operations...

Thanks and sorry for the noise...

--
Pietro Cerutti

PGP Public Key:http://gahr.ch/pgp- Hide quoted text -

- Show quoted text -
But be careful under C89:
This compiles fine with no complaints:

void foo() {
int i;
int j;;

i = 2;
/* more code here */
}

But then you decide to add another variable:

void foo() {
int i;
int j;;
int k;

i = 2;
/* more code here */
}

Now the compiler complains, and you have a hard time trying to
figure out why adding "int k;" could cause a problem.
--
Fred Kleinschmidt
Jan 24 '08 #4
fr*****************@boeing.com wrote:
On Jan 24, 4:00 am, Pietro Cerutti <gahr_AT_gahr_DOT_ch_DO_NOT_SPAM>
wrote:
>Malcolm McLean wrote:
>>"Pietro Cerutti" <gahr_AT_gahr_DOT_ch_DO_NOT_SPAMwrote in message
news:ec***************************@news.hispeed. ch...
Hi group,
is the below valid?
int main(void)
{
int i = 4;;;;;;;;
}
It compiles cleanly with GCC -Wall.
I don't see any reason for that, any clarification is welcome!
The null statement is allowed.
It means you can do things like
/* execute foo() until it return a zero */
while( foo() );
instead of having to write
while( foo() )
continue;
Obviously your example was pointless, but it would be harder to forbid
it than to allow it.
Obvious... my example (which comes from a typo I did) was so pointless
that I didn't see it as a sequence of null operations...

Thanks and sorry for the noise...

--
Pietro Cerutti

PGP Public Key:http://gahr.ch/pgp- Hide quoted text -

- Show quoted text -

But be careful under C89:
This compiles fine with no complaints:

void foo() {
int i;
int j;;

i = 2;
/* more code here */
}

But then you decide to add another variable:

void foo() {
int i;
int j;;
int k;

i = 2;
/* more code here */
}

Now the compiler complains, and you have a hard time trying to
figure out why adding "int k;" could cause a problem.
Very sharp point. Thanks!
--
Fred Kleinschmidt

--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Jan 24 '08 #5

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

Similar topics

8
by: EAS | last post by:
Hey, I'm new to python (and programming in general) so I'll prolly be around here a lot... Anyways, I've found out how to make a "guess my number game" where the player guesses a number between...
1
by: Mage | last post by:
Hello, I amafraid of I will stop using semicolons in other languages after one or two months of python. However I see that python simply ignores the semicolons atd the end of the lines. ...
11
by: don | last post by:
Ok, this is a homework assignment, but can you help me out anyway...... I need a routine for figuring out if a number inputted by the user is a prime number or not...... all I'm asking for is Not...
1
by: jjbutera | last post by:
How do I escape these? The backslash doesn't seem to be working.
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
27
by: Jeremy Yallop | last post by:
Write a program that takes a C program in source form as input and prints the source code for a program with equivalent behaviour, but without semicolons, on standard output. Please note that...
9
by: cw bebop | last post by:
Hi all Using Visual Studio C# Have a string string st = "Hi, these pretzels are making me thirsty; drink this tea. Run like heck." ******
3
by: Stefan Mueller | last post by:
I've a web page with several input boxes. After the user clicks 'submit' I insert these data into my MySQL database. This worked for several months perfect. But today a user entered the street...
19
by: gk245 | last post by:
Trying to write a program that will figure out if a number is perfect or not. Here is my logic: 1) Read in the number 2) Split it up (number - 1) 3) Put all the split up numbers into an...
3
by: floofy | last post by:
Hello all! First I would like to thank all of those who helped me regarding my first assignment...I'm much better with my semicolons now. A couple assignments later...I'm having problems again....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.