public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc 9.5.0 compiler error: identifier "__builtin_is_constant_evaluated" is undefined
@ 2023-05-08 18:59 Baribault, Carl
  2023-05-08 20:05 ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: Baribault, Carl @ 2023-05-08 18:59 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 150 bytes --]

Dear Help,

The subject identifier is nowhere defined.

Please let me know if you need any more information. Thank you.


Best,
C. Baribault

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc 9.5.0 compiler error: identifier "__builtin_is_constant_evaluated" is undefined
  2023-05-08 18:59 gcc 9.5.0 compiler error: identifier "__builtin_is_constant_evaluated" is undefined Baribault, Carl
@ 2023-05-08 20:05 ` Jonathan Wakely
  2023-05-08 20:27   ` Jonathan Wakely
  2023-05-08 21:33   ` Baribault, Carl
  0 siblings, 2 replies; 5+ messages in thread
From: Jonathan Wakely @ 2023-05-08 20:05 UTC (permalink / raw)
  To: Baribault, Carl; +Cc: gcc-help

[-- Attachment #1: Type: text/plain, Size: 485 bytes --]

On Mon, 8 May 2023, 20:00 Baribault, Carl via Gcc-help, <
gcc-help@gcc.gnu.org> 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
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc 9.5.0 compiler error: identifier "__builtin_is_constant_evaluated" is undefined
  2023-05-08 20:05 ` Jonathan Wakely
@ 2023-05-08 20:27   ` Jonathan Wakely
  2023-05-08 21:33   ` Baribault, Carl
  1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Wakely @ 2023-05-08 20:27 UTC (permalink / raw)
  To: Baribault, Carl; +Cc: gcc-help

On Mon, 8 May 2023 at 21:05, Jonathan Wakely wrote:
>
>
>
> On Mon, 8 May 2023, 20:00 Baribault, Carl via Gcc-help, <gcc-help@gcc.gnu.org> 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?

Here's the proof it is defined:
https://godbolt.org/z/cWK7fzYxK

Maybe you're trying to use it in C code instead of C++?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc 9.5.0 compiler error: identifier "__builtin_is_constant_evaluated" is undefined
  2023-05-08 20:05 ` Jonathan Wakely
  2023-05-08 20:27   ` Jonathan Wakely
@ 2023-05-08 21:33   ` Baribault, Carl
  2023-05-08 22:55     ` Jonathan Wakely
  1 sibling, 1 reply; 5+ messages in thread
From: Baribault, Carl @ 2023-05-08 21:33 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-help

[-- Attachment #1: Type: text/plain, Size: 4007 bytes --]

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.


$ 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++, and only occurs using Intel's icpc with GNU/g++ headers.


$ 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@gmail.com>
Sent: Monday, May 8, 2023 3:05 PM
To: Baribault, Carl <cbaribault@tulane.edu>
Cc: gcc-help <gcc-help@gcc.gnu.org>
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@gcc.gnu.org<mailto:gcc-help@gcc.gnu.org>> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc 9.5.0 compiler error: identifier "__builtin_is_constant_evaluated" is undefined
  2023-05-08 21:33   ` Baribault, Carl
@ 2023-05-08 22:55     ` Jonathan Wakely
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Wakely @ 2023-05-08 22:55 UTC (permalink / raw)
  To: Baribault, Carl; +Cc: gcc-help

[-- Attachment #1: Type: text/plain, Size: 5075 bytes --]

On Mon, 8 May 2023, 22:33 Baribault, Carl, <cbaribault@tulane.edu> 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@gmail.com>
> *Sent:* Monday, May 8, 2023 3:05 PM
> *To:* Baribault, Carl <cbaribault@tulane.edu>
> *Cc:* gcc-help <gcc-help@gcc.gnu.org>
> *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@gcc.gnu.org> 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
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-08 22:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-08 18:59 gcc 9.5.0 compiler error: identifier "__builtin_is_constant_evaluated" is undefined Baribault, Carl
2023-05-08 20:05 ` Jonathan Wakely
2023-05-08 20:27   ` Jonathan Wakely
2023-05-08 21:33   ` Baribault, Carl
2023-05-08 22:55     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).