473,320 Members | 1,950 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,320 software developers and data experts.

missing return statement on non void functions; just a warning?

I'm wondering what was the rationale that caused gcc to only have a
warning (disabled by default!!) to signal the following:

int a()
{}; // intentionally no statements

int main()
{
printf("%d", a());
return 0;
}

Function a() is declared as returning an int and the compiler doesn't
treat as an error the missing return statement.
I'm asking in this forum because I suspect that gcc crowd will just
tell me to read the standard. If I'm in the wrong forum, I hope to be
corrected.

Thank you,
Adrian
Feb 8 '08 #1
1 3581
macracan wrote:
I'm wondering what was the rationale that caused gcc to only have a
warning (disabled by default!!) to signal the following:

int a()
{}; // intentionally no statements

int main()
{
printf("%d", a());
return 0;
}

Function a() is declared as returning an int and the compiler doesn't
treat as an error the missing return statement.
I'm asking in this forum because I suspect that gcc crowd will just
tell me to read the standard. If I'm in the wrong forum, I hope to be
corrected.
You must have compiled it as C, it certainly won't compile as C++.

--
Ian Collins.
Feb 8 '08 #2

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

Similar topics

1
by: Junior | last post by:
I keep receiving this "The type or namespace name 'CASsEventHandler' could not be found (are you missing a using directive or an assembly reference?)" message in two particular lines, and I've...
15
by: Greenhorn | last post by:
Hi, when a function doesn't specify a return type ,value what value is returned. In the below programme, the function sample()is returning the value passed to 'k'. sample(int); main() { int...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
5
by: Dmitriy Lapshin [C# / .NET MVP] | last post by:
Hi all, I think the VB .NET compiler should at least issue a warning when a function does not return value. C# and C++ compilers treat this situation as an error and I believe this is the right...
3
by: Allerdyce.John | last post by:
Hi, In my code, I have a function which has a return value in the declaration: bool myFunction( int a) { // my implmentation }
20
by: lovecreatesbeauty | last post by:
Hello experts, Is the following code snippet legal? If it is, how can exit() do the keyword return a favor and give a return value to the main function? Can a function call (or only this...
9
by: Christian Christmann | last post by:
Hi, do I have to provide the return type when a function is declared in ANSI C-99? Or would main ( void ) { ... } be enough?
12
by: Pawel | last post by:
Hallo group members Could You tell hw to write this code in order not to get warning from subject: #include <iostream> using namespace std; using namespace __gnu_cxx; struct entry {
12
by: tfelb | last post by:
Hi all! I bought the book "Programming in C" by Stephen G Kochan. I miss 2 answers at his website. (removestr and the substr function) How can I implement these functions? It would be wonderful...
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.