This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/80801] New: Error "void value not ignored as it ought to be" is a bit cryptic
- From: "gcc at martinien dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 17 May 2017 09:35:34 +0000
- Subject: [Bug c/80801] New: Error "void value not ignored as it ought to be" is a bit cryptic
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80801
Bug ID: 80801
Summary: Error "void value not ignored as it ought to be" is a
bit cryptic
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: gcc at martinien dot de
Target Milestone: ---
This code returns a not-very-intuitive error:
$ cat void.cpp
void func()
{
}
int main()
{
return func();
}
$ g++ -c void.cpp
void.cpp: In function 'int main()':
void.cpp:7:15: error: void value not ignored as it ought to be
return func();
^
In this small example it is clear, for complex code it might not be obvious
what the error is.
clang is a little bit more helpful:
void.cpp:7:10: error: cannot initialize return object of type 'int' with an
rvalue of type 'void'
return func();
^~~~~~
1 error generated.
Best regards,
Martin