x42 / tuna.lv2

Musical Instrument Tuner
http://x42-plugins.com/x42/x42-tuner
GNU General Public License v2.0
26 stars 8 forks source link

Errors/warnings from clang-6 compiler #7

Closed yurivict closed 6 years ago

yurivict commented 6 years ago

I'm getting these errors in the FreeBSD port:

In file included from src/tuna.c:70:
src/spectr.c:136:32: error: implicit conversion from '_Complex int' to 'double' is not permitted in C++
                complex_t p = cos (omega) +  _I * sin (omega);
                                             ^~
src/spectr.c:33:26: note: expanded from macro '_I'
# define _I ((complex_t)(1i))
             ~           ^~
src/spectr.c:148:66: error: implicit conversion from '_Complex int' to 'double' is not permitted in C++
                const complex_t u0 = ab_2 + creal(v * -1.) + ab_2 * creal(c) + _I * (cimag(v * -1.) + ab_2 * cimag(c));
                                                                               ^~
src/spectr.c:33:26: note: expanded from macro '_I'
# define _I ((complex_t)(1i))
             ~           ^~
src/spectr.c:149:61: error: implicit conversion from '_Complex int' to 'double' is not permitted in C++
                const complex_t u1 = ab_2 + creal( v) + ab_2 * creal(c) + _I * (cimag( v) + ab_2 * cimag(c));
                                                                          ^~
src/spectr.c:33:26: note: expanded from macro '_I'
# define _I ((complex_t)(1i))
             ~           ^~
src/spectr.c:175:8: error: implicit conversion from '_Complex int' to 'double' is not permitted in C++
                          + _I * ((fb->f[i].W[b1] * sin_w) + sin_w2);
                            ^~
src/spectr.c:33:26: note: expanded from macro '_I'
# define _I ((complex_t)(1i))
             ~           ^~
src/spectr.c:177:8: error: implicit conversion from '_Complex int' to 'double' is not permitted in C++
                          + _I * ((fb->f[i].W[a1] * sin_w) + fb->f[i].W[a2] * sin_w2);
                            ^~
src/spectr.c:33:26: note: expanded from macro '_I'
# define _I ((complex_t)(1i))
             ~           ^~
src/tuna.c:806:9: warning: absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value [-Wabsolute-value]
                                if (fabsf(self->dll_e0 * freq / self->rate) > .02) {
                                    ^
src/tuna.c:806:9: note: use function 'std::abs' instead
                                if (fabsf(self->dll_e0 * freq / self->rate) > .02) {
                                    ^~~~~
                                    std::abs
yurivict commented 6 years ago

clang-5.0.1

x42 commented 6 years ago

Are you using tuna v0.4.4 ? this should be fixed since 06d32a0a9bd67

yurivict commented 6 years ago

I'm using tuna in x42-plugins bundle version 20170428. Not sure where to see the latest version.

x42 commented 6 years ago

April last year? hmm. See https://github.com/x42/x42-plugins#releases Latest is currently 20180320 from last week: https://gareus.org/misc/x42-plugins/x42-plugins-20180320.tar.xz

x42 commented 6 years ago

Anyway, could you try git-head of this repo? that should also fix the -Wabsolute-value

yurivict commented 6 years ago

Ok, thanks. I will update the FreeBSD port, and in a day or two will see if there is any fallout from any systems.

yurivict commented 6 years ago

20180320 still has the same errors. It uses this tarball: http://gareus.org/misc/x42-plugins/x42-plugins-20180320.tar.xz

x42 commented 6 years ago

I have no explanation, nor can I reproduce this. src/spectr.c:37 has a typedef std::complex<double> complex_t; there's no _Complex int involved.

yurivict commented 6 years ago

Do you use clang? This happens with clang-6.0.0

x42 commented 6 years ago

Not with clang-5.0.1.

I test with clang 3.8.1-24 (GNU/Linux) and clang-3.0.0 (MacOS) as well with gcc-4.0 (OSX) and gcc 4,5,6 on Linux and mingw 4.9 and 6.3

yurivict commented 6 years ago

Maybe it's only in clang-6.0.0.

x42 commented 6 years ago

I currently don't have a build-environment with clang-5 or clang-6 (nor with gcc-8), so I cannot test those myself, I'm sorry.

Perhaps it helps to ask for an older C++ standard? make CXXFLAGS="-std=c++98" That would avoid the define in line 33

yurivict commented 6 years ago

Perhaps it helps to ask for an older C++ standard? make CXXFLAGS="-std=c++98" That would avoid the define in line 33

Since the error occurs in .c file, c++98 can't help.

x42 commented 6 years ago

Check the output of make. The file is compiled with CXX (here clang++) for the standalone jack-app:

$ CC=clang CXX=clang++ make CXXFLAGS="-std=c++98"
Version: 0.4.4-1 -> 0 4 4 1
LV2 Version: 1033 3
test -d .git -a .gitmodules -a -f Makefile.git && make -f Makefile.git submodule_check
make[1]: Entering directory '/home/rgareus/data/coding/tuna.lv2'
make[1]: Leaving directory '/home/rgareus/data/coding/tuna.lv2'
clang  -Wall -g -Wno-unused-function -DHAVE_LV2_1_8 -g -msse -msse2 -mfpmath=sse -ffast-math -fomit-frame-pointer -O3 -fno-finite-math-only -DNDEBUG -DVERSION="\"0.4.4-1\"" `pkg-config --cflags lv2 fftw3f` -fPIC -fvisibility=hidden `pkg-config --cflags cairo pangocairo pango` -Irobtk/ -DDISPLAY_INTERFACE   -std=c99 \
  -o build/tuna.so src/tuna.c \
  -shared -Wl,-Bstatic -Wl,-Bdynamic -Wl,--as-needed -pthread  -lm `pkg-config --libs lv2 fftw3f` `pkg-config  --libs cairo pangocairo pango` 
strip -s build/tuna.so
clang++  -I. -Wall -g -Wno-unused-function -DHAVE_LV2_1_8 -g -msse -msse2 -mfpmath=sse -ffast-math -fomit-frame-pointer -O3 -fno-finite-math-only -DNDEBUG -DVERSION="\"0.4.4-1\"" `pkg-config --cflags lv2 fftw3f` -fPIC -fvisibility=hidden `pkg-config --cflags cairo pangocairo pango` -Irobtk/ -DDISPLAY_INTERFACE -std=c++98  `pkg-config --cflags jack lv2 pango pangocairo glu gl` -pthread `pkg-config  --cflags liblo` -DHAVE_LIBLO -DDEFAULT_NOT_ONTOP \
  -DXTERNAL_UI -DHAVE_IDLE_IFACE \
  -DJACK_DESCRIPT="\"lv2ttl/plugins.h\"" \
  -DAPPNAME="\"tuna\"" \
  -o x42/x42-tuna-collection \
  robtk/jackwrap.c robtk/pugl/pugl_x11.c   \
  -DX42_MULTIPLUGIN src/tuna.c x42/x42-tuna.o \
   -lm -lm `pkg-config --libs lv2 fftw3f` `pkg-config  --libs cairo pangocairo pango` -lX11 `pkg-config  --libs cairo pango pangocairo glu gl`   `pkg-config  --libs jack` `pkg-config  --libs liblo`
strip -s x42/x42-tuna-collection
yurivict commented 6 years ago

Ok, but adding -std=c++98 didn't fix the problem.

x42 commented 6 years ago

Could you please include the compiler invocation with the error message?

With -std=c++98 it is not not possible to reach src/spectr.c:33 (except on OSX) so there must be a different error.

yurivict commented 6 years ago

I think this is a clang bug: https://bugs.llvm.org/show_bug.cgi?id=36915 Closing it here.

Thank you for your help!