Re: gcc 9.5.0 compiler error: identifier "__builtin_is_constant_evaluated" is undefined

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 8 May 2023, 22:33 Baribault, Carl, <cbaribault@xxxxxxxxxx> wrote:

> Hi Jonathan,
>
> Thanks for your reply.
>
> I've installed gcc 9.5.0 on our campus cluster under
> /share/apps/centos7/gcc/9.5.0.
>
> When I search for that function name among the installed files, I see it
> used multiple times, but I don't see that function defined anywhere.
> Please advise, thanks.
>

It's a compiler built-in. The clue is in the name.

It's defined by the compiler.



> $ grep -r __builtin_is_constant_evaluated /share/apps/centos7/gcc/9.5.0
>
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/bit:      if (!
> *__builtin_is_constant_evaluated*())
>
>
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/x86_64-pc-linux-gnu/bits/c++config.h
> :# if __has_builtin(*__builtin_is_constant_evaluated*)
>
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/type_traits:  { return
> *__builtin_is_constant_evaluated*(); }
>
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/bits/stl_function.h: if (
> *__builtin_is_constant_evaluated*())
>
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/bits/stl_function.h: if (
> *__builtin_is_constant_evaluated*())
>
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/bits/stl_function.h: if (
> *__builtin_is_constant_evaluated*())
>
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/bits/stl_function.h: if (
> *__builtin_is_constant_evaluated*())
>
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/bits/char_traits.h:      return
> *__builtin_is_constant_evaluated*();
>
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/bits/char_traits.h:      return
> *__builtin_is_constant_evaluated*();
>
> Binary file
> /share/apps/centos7/gcc/9.5.0/libexec/gcc/x86_64-pc-linux-gnu/9.5.0/cc1plus
> matches
>
> Also, here's the error message.
>
> In file included from
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/bits/ios_base.h(46),
>
>                  from
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/ios(42),
>
>                  from
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/ostream(38),
>
>                  from
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/iostream(39),
>
>                  from pic.cpp(6):
>
> /share/apps/centos7/gcc/9.5.0/include/c++/9.5.0/bits/stl_function.h(437):
> error: identifier "__builtin_is_constant_evaluated" is undefined
>
>         if (__builtin_is_constant_evaluated())
>
>             ^
>
>
> compilation aborted for pic.cpp (code 2)
>
> Also, granted this error does not occur compiling pic.cpp using g++,
>

Right, so when you said "gcc 9.5.0: compiler error" in the email Subject,
you meant something different. Because it is defined by gcc, and you don't
get an error with gcc.




and only occurs using Intel's icpc with GNU/g++ headers.
>

That was essential information that was completely missing from your first
email.

The problem is that Intel's compiler defines the __GNUC__ macro to the same
value as the system gcc, which means that it's identifying itself as gcc 9,
and so libstdc++ headers assume it supports all the same built-ins as gcc 9.

The built-in was added to gcc more than 4 years ago, and will have been
supported by Intel's compiler soon after. Have you tried updating your
Intel compiler? If I understand correctly, old versions of the Intel
compiler are unsupported, you should always be using an up to date version.



> $ cat pic.cpp
>
> // C++ program to estimate value of pi
>
> // See discussion for Improved Say of Determining Pi at
>
> //  http://mb-soft.com/public3/pi.html  (retrieved March 2017)
>
> // If we integrate 1/(1+x^2) for x=0:1, we get pi/4
>
>
> #include <iostream>
>
> #include <iomanip>
>
> #include <cstdlib>
>
>
> using std::cout;
>
>
> int main(int argc, char* argv[])
>
> {
>
>   long i, nsteps;
>
>   double pi, step, sum = 0.0;
>
>   nsteps = 0;
>
>   if (argc > 1)
>
>     nsteps = atol(argv[1]);
>
>   if (nsteps <= 0)
>
>     nsteps = 100;
>
>   step = (1.0)/((double)nsteps);
>
>   for (i = 0; i < nsteps; ++i) {
>
>     double x = ((double)i+0.5)*step;
>
>     sum += 1.0 / (1.0 + x * x);
>
>   }
>
>   pi = 4.0 * step * sum;
>
>   cout << std::fixed;
>
>   cout << "pi is " << std::setprecision(17) << pi << "\n";
>
> }
>
> ------------------------------
> *From:* Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
> *Sent:* Monday, May 8, 2023 3:05 PM
> *To:* Baribault, Carl <cbaribault@xxxxxxxxxx>
> *Cc:* gcc-help <gcc-help@xxxxxxxxxxx>
> *Subject:* Re: gcc 9.5.0 compiler error: identifier
> "__builtin_is_constant_evaluated" is undefined
>
>
> External Sender. Be aware of links, attachments and requests.
>
>
> On Mon, 8 May 2023, 20:00 Baribault, Carl via Gcc-help, <
> gcc-help@xxxxxxxxxxx> wrote:
>
> Dear Help,
>
> The subject identifier is nowhere defined.
>
> Please let me know if you need any more information. Thank you.
>
>
> Yes, we need more info, you've provided none at all.
>
> That is a built-in function provided by the compiler, present since gcc
> 9.1.0
>
> In what context are you seeing it not defined? What are you trying to do,
> and what error do you get?
>
>
>
>
>
>
> Best,
> C. Baribault
>
>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux