This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/71592] Add some facilities for compile-time check
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 22 Jun 2016 05:29:05 +0000
- Subject: [Bug fortran/71592] Add some facilities for compile-time check
- Auto-submitted: auto-generated
- References: <bug-71592-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71592
--- Comment #4 from Jakub Jelinek <jakub 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.
You are either not showing the intended use, or misunderstanding what
_Static_assert is. _Static_assert is a compile time assertion during parsing.
The expression in it must be integral constant expression, otherwise you get
error. So, you certainly can't use a function argument in there.
> 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.
You are mixing the order, $! means nothing, !$ followed by space or & is OpenMP
conditional compilation, !$omp is OpenMP directive, !$acc is OpenACC directive.