[Piglit] [PATCH 1/3] android: piglit-vbo.cpp compile error
Paul Berry
stereotype441 at gmail.com
Mon Jan 28 18:33:40 PST 2013
On 28 January 2013 17:18, Matt Turner <mattst88 at gmail.com> wrote:
> On Mon, Jan 28, 2013 at 5:11 PM, Tom Gall <tom.gall at linaro.org> wrote:
> > Sure, but tell that to the compiler.
> >
> > It is bad form to not have a return at the end of a function which is
> > supposed to return something. The other way perhaps is just knock out
> > the default case and return that. Either way.
>
> % cat t.cpp
> #include <assert.h>
>
> int f(int n) {
> switch (n) {
> case 1:
> return 1;
> default:
> assert(!"FAIL");
> }
> }
>
> % gcc -O2 -Wall -pedantic -Wreturn-type -Wno-return-type -c t.cpp
>
> <no output>
>
> What flags do I have to use to get an error or warning? I tried with
> an without optimization, C and C++, and gcc versions 4.5.4, 4.6.3, and
> 4.7.2.
>
Keep in mind that when the "NDEBUG" symbol is defined, assertions have no
effect, so it's possible for control flow to get past an assert(!"FAIL")
statement.
This produces the warning for me:
gcc -DNDEBUG -Wreturn-type -c t.cpp
Given that some people compile Piglit with NDEBUG and some people compile
it without, I think Tom's patches 2/3 and 3/3 are reasonable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130128/29a1858f/attachment.html>
More information about the Piglit
mailing list