grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.58k stars 322 forks source link

error.dsp.cpp:15980:46: error: ‘inf’ was not declared in this scope #397

Closed magnetophon closed 4 years ago

magnetophon commented 4 years ago

When I compile this:

import("stdfaust.lib");

slidingMult(n,maxn,x) = ba.slidingReduce(*,n,maxn,1,x);
slidingGeometricMean(n,maxn,x) = pow(slidingMult(n,maxn,x),1.0/n);

maxMeanNr = pow(2,14);

process =
  (_*2:slidingGeometricMean(maxMeanNr,maxMeanNr)/2);

I get:


end generateCode (duration : 0.216577)
In file included from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtkobject.h:37,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtkwidget.h:36,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtkcontainer.h:35,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtkbin.h:35,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtkwindow.h:36,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtkdialog.h:35,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtkaboutdialog.h:32,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtk.h:33,
                 from error.dsp.cpp:2097:
/nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtktypeutils.h:236:64: warning: ‘GTypeDebugFlags’ is deprecated [-Wdeprecated-declarations]
 void            gtk_type_init   (GTypeDebugFlags    debug_flags);
                                                                ^
In file included from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/gobject/gobject.h:24,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/gobject/gbinding.h:29,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/glib-object.h:23,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/gio/gioenums.h:28,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/gio/giotypes.h:28,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/gio/gio.h:26,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gdk/gdk.h:32,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtk.h:32,
                 from error.dsp.cpp:2097:
/nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/gobject/gtype.h:679:1: note: declared here
 {
 ^
In file included from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtktoolitem.h:31,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtktoolbutton.h:30,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtkmenutoolbutton.h:30,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtk.h:126,
                 from error.dsp.cpp:2097:
/nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtktooltips.h:73:12: warning: ‘GTimeVal’ is deprecated: Use 'GDateTime' instead [-Wdeprecated-declarations]
   GTimeVal last_popdown;
            ^~~~~~~~~~~~
In file included from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/glib/galloca.h:32,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/glib.h:30,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/gobject/gbinding.h:28,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/glib-object.h:23,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/gio/gioenums.h:28,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/gio/giotypes.h:28,
                 from /nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/gio/gio.h:26,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gdk/gdk.h:32,
                 from /nix/store/psxjacrypr6h16r9jzzh8ngf9z1gynzq-gtk+-2.24.32-dev/include/gtk-2.0/gtk/gtk.h:32,
                 from error.dsp.cpp:2097:
/nix/store/jgdnddcsnrjwhdzfxbma353v6bn7y8m8-glib-2.62.3-dev/include/glib-2.0/glib/gtypes.h:549:26: note: declared here
 typedef struct _GTimeVal GTimeVal GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime);
                          ^~~~~~~~
error.dsp.cpp: In member function ‘virtual void mydsp::compute(int, float**, float**)’:
error.dsp.cpp:15980:46: error: ‘inf’ was not declared in this scope
    output0[i] = FAUSTFLOAT((0.5f * std::pow((inf.0f * (fTemp13 * fVec13[((IOTA - 8192) & 16383)])), 6.10351562e-05f)));
                                              ^~~
error.dsp.cpp:15980:46: note: suggested alternative: ‘ynf’
    output0[i] = FAUSTFLOAT((0.5f * std::pow((inf.0f * (fTemp13 * fVec13[((IOTA - 8192) & 16383)])), 6.10351562e-05f)));
                                              ^~~
                                              ynf
error.dsp.cpp:111:20: error: expected primary-expression before ‘float’
 #define FAUSTFLOAT float
                    ^~~~~
error.dsp.cpp:15980:17: note: in expansion of macro ‘FAUSTFLOAT’
    output0[i] = FAUSTFLOAT((0.5f * std::pow((inf.0f * (fTemp13 * fVec13[((IOTA - 8192) & 16383)])), 6.10351562e-05f)));

If I slightly change the code, it works:

1) same code, smaller blocksize.

maxMeanNr = pow(2,4);

process =
  (_*2:slidingGeometricMean(maxMeanNr,maxMeanNr)/2);

or same blocksize, no mult and div

maxMeanNr = pow(2,14);

process =
  slidingGeometricMean(maxMeanNr,maxMeanNr);

or using Mean instead of Geometric Mean, which are very similar functions:

maxMeanNr = pow(2,14);

process =
  (_*2:ba.slidingMeanN(maxMeanNr,maxMeanNr)/2);

This one breaks in another way:

maxMeanNr = pow(2,14);

process =
  (_*2:slidingMult(maxMeanNr,maxMeanNr)/2);

It gives:

error.dsp.cpp: In member function ‘virtual void mydsp::compute(int, float**, float**)’:
error.dsp.cpp:15980:29: error: ‘inf’ was not declared in this scope
    output0[i] = FAUSTFLOAT((inf.0f * (fTemp13 * fVec13[((IOTA - 8192) & 16383)])));
                             ^~~
error.dsp.cpp:15980:29: note: suggested alternative: ‘ynf’
    output0[i] = FAUSTFLOAT((inf.0f * (fTemp13 * fVec13[((IOTA - 8192) & 16383)])));
                             ^~~
                             ynf
error.dsp.cpp:111:20: error: expected primary-expression before ‘float’
 #define FAUSTFLOAT float
                    ^~~~~
error.dsp.cpp:15980:17: note: in expansion of macro ‘FAUSTFLOAT’
    output0[i] = FAUSTFLOAT((inf.0f * (fTemp13 * fVec13[((IOTA - 8192) & 16383)])));

I'm not sure how to narrow it down further.

sletz commented 4 years ago

I understand the code does some computation at compile time that produce an INFINITY value. Then the C++ generated code indeed is incorrect and does not compile, which is a bug that we have to fix in the compiler, that is detect this INFINITY value, and returns a proper error message to the user.

But on your side, for now, you'll have to fix your DSP source to make it avoid this INFINITY case.

magnetophon commented 4 years ago

How would I find it in the first place? I'm not using INFINITY in that function and I just grepped the libraries and the only use of it is in my sliding min and max functions.

sletz commented 4 years ago

Some computation done at compile time (pattern matching I guess....), that makes a computation goes out of the float range. INFINITY (see here https://en.cppreference.com/w/c/numeric/math/INFINITY) probably appears as a result of a computation.

magnetophon commented 4 years ago

I can't imagine why

maxMeanNr = pow(2,14);

(_*2:slidingGeometricMean(maxMeanNr,maxMeanNr)/2);)

would produce INFINITY at compile time, when

maxMeanNr = pow(2,14);

process =
  slidingGeometricMean(maxMeanNr,maxMeanNr);

works fine.

I know very little about the internals of faust, but that doesn't make sense. Also that it only happens with bigger blocksizes baffles me.

sletz commented 4 years ago

I'll have to look more deeply.

magnetophon commented 4 years ago

Thanks!

sletz commented 4 years ago

After some discussions here: