More warnings with -Wconversion!


#1

Since implicit conversion warnings are not 'on' by default in GCC or Clang, and not part of -Wall, I decided to give it a shot.

It worked out great for my code, and gave me all the same implicit conversion warnings Visual Studio does... and more!

This flag seems more strict and thorough than VS, and pointed out a wad of conversions in JUCE. There are some fishy ones, like passing signed integers (which may be set to -1 by JUCE) to OpenGL functions that support only unsigned integers.

Note that I'm testing using the Demo.

Example:

openGLContext.extensions.glVertexAttribPointer (position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), 0);

Where attributeID is a GLint, and glVertexAttribPointer() takes a GLuint for first parameter. The same applies to glEnableVertexAttribArray(), too...

The JUCE docs say that attributeID will be <0 if the uniform could not be found; this seems like the potential for bizarre run-time issues...


#2

Ah, thanks.. I thought I'd already nailed all of those, but I guess the projects in which I've enabled that flag don't include modules like openGL, so I've missed a few warnings. Will skip through and sort that out!


#3

Using the tip… just a few left…

Let me know if you need line numbers, but I think the file names should indicate the modules.

Cheers,

Rail


#4

Have you tried the vs 2015 compiler preview? It generates a lot of new warnings. Most are just cases where local names hides globals / members, but there are a couple of cases with inconsistent alignment specifications, unsafe functions and at one point I saw a place with an apparantly unavoidable recursion, but can't trace it currently..


#5

I can't see those warnings at all (?)

I've definitely been building those files with -Wconversion, so not sure why you'd see them and I don't.. 

 


#6

You must be using a Base SDK of 10.10 – I’m using an earlier base.

Cheers,

Rail