blob: 3b8821d2c4653a5eb5fb921f7f33ea62946c196b [file] [log] [blame] [edit]
// Copyright 2019-2024 The Khronos Group. This work is licensed under a
// Creative Commons Attribution 4.0 International License; see
// http://creativecommons.org/licenses/by/4.0/
[[diff2cxx]]
=== Difference to {cpp}
{cpp} for OpenCL supports the majority of standard {cpp}17 features,
however, there are some differences that are documented in this section.
==== Restrictions to {cpp} features
The following {cpp} language features are not supported:
* Virtual functions ({cpp}17 `[class.virtual]`);
* References to functions ({cpp}17 `[class.mfct]`);
* Pointers to class member functions (in addition to the regular non-member
functions that are already restricted in OpenCL C);
* Exceptions ({cpp}17 `[except]`);
* `dynamic_cast` operator ({cpp}17 `[expr.dynamic.cast]`);
* Non-placement `new`/`delete` operators ({cpp}17
`[expr.new]`/`[expr.delete]`);
* `thread_local` storage class specifier ({cpp}17 `[basic.stc.thread]`);
* Standard C++ libraries ({cpp}17 `[library]`).
:fn-feature-macro: footnote:[The macro belongs to the list of {cpp}20's \
feature test macros.]
Simultaneous initialization of static local objects performed by
different work-items is not guaranteed to be free from race-conditions.
Whether an implementation provides such a guarantee is indicated by the
presence of the `+__cpp_threadsafe_static_init+` feature test
macro{fn-feature-macro}.
The list above only contains extra restrictions that are not detailed in OpenCL
C specification. As OpenCL restricts a number of C features, the same restrictions
are inherited by C++ for OpenCL. The detailed list of C feature restrictions
is provided in `OpenCL C 3.0 s6.11`.