https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71592
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |kargl at gcc dot gnu.org Resolution|--- |WONTFIX --- Comment #3 from kargl at gcc dot gnu.org --- (In reply to 鍾 from comment #2) > (In reply to Jakub Jelinek from comment #1) > > You can't use such static_assert this way in C++, unless the function is > > constexpr, nor in C (always), so guess you are proposing something > > completely different (like, if this function/subroutine is inlined and the > > expression is after inlining/optimizations constant, then see if it is true > > or false, otherwise do nothing. So more like > > if (__builtin_constant_p (r >= 0.0)) > > { > > if (!(r >= 0.0)) __builtin_warning ("..."); > > } > > Also, !$ already has a specific meaning in OpenMP, so it would be a bad idea > > to abuse it. > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39462 > Please read this bug-report page. static assert is now part of C11 standard. > And can be used in 4.7 and above with _Static_assert keyword. > > Actually, This kind of "static check" need not to alter any > function/subroutine body. It added and used by the consumer of > functions/subroutine. no relate to inlining and optimization anything. It > signed as "$!" on the function declaration or function implementation(so it > don't reserved on real execution code, works only on current compilation > unit if the compiler recognize this directive). "$!" is not only used by > OpenMP($!omp), but also used by OpenACC($!openacc), and used to import or > export the dll function on ivf($!DEV DLLIMPORT or $!DEV DLLEXPORT), etc. Just use the pre-processor. % cat a.F90 program foo external mysqrt real x, mysqrt x = -1. #ifdef EBUG if (x < 0) then stop "I'm an idiot to call mysqrt() with a negative arg" end if #endif print *, mysqrt(x) end program foo function mysqrt(x) real x, mysqrt mysqrt = sqrt(x) end function % gfc -o z -DEBUG a.F90 && ./z STOP I'm an idiot to call mysqrt() with a negative arg % gfc -o z a.F90 && ./z NaN