Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6576861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:33:51+00:00 2026-05-25T15:33:51+00:00

I was told that C and C++ have undefined behavior, that is, the same

  • 0

I was told that C and C++ have “undefined behavior”, that is, the same code might behave differently on different platforms, or using different compilers, if I use “certain constructs”.

Does the same apply to OpenCL and/or OpenGL SL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:33:52+00:00Added an answer on May 25, 2026 at 3:33 pm

    Yes, according to the OpenCL specification 1.1 which defines undefined behaviour in the front matter as:

    The behavior of an OpenCL API call, built-in function used
    inside a kernel or execution of a kernel that is explicitly not
    defined by OpenCL. A conforming implementation is not required to
    specify what occurs when an undefined construct is encountered in
    OpenCL

    For example:

    • Section 5.2.1 defines several:
      • “Reading from a buffer or image object created with CL_MEM_WRITE_ONLY inside a kernel”
      • “Writing to a buffer or image object created with CL_MEM_READ_ONLY inside a kernel”
      • “OpenCL commands that operate on multiple
        buffer objects created with the same host_ptr or
        overlapping host regions”
      • “Concurrent reading from, writing to and copying between overlapping
        sub-buffer objects created with the same buffer object”
    • Section 5.2.2 also defines a few:
      • clEnqueueReadBuffer with other commands using the buffer
      • clEnqueueReadBuffer whilst the buffer is mapped

    There’s plenty more ways of invoking undefined behaviour from OpenCL though.

    For OpenGL SL (specification) there are quite a few easy to find examples:

    • “Undefined behavior results from indexing an array with a non-constant expression that’s greater than or equal to the array’s size or less than 0” (Interestingly if it’s a const then it’s a compile time error)
    • Likewise for accessing vector elements with array subscript notation
    • “Reading a varying variable in a
      vertex shader returns undefined values if it is read before being written”
    • “If this pragma [#pragma STDGL invariant(all)] is used after the declaration of any variables or
      functions, then the set of outputs that behave as invariant is undefined”
    • “Reading [gl_PointSize or gl_ClipVertex] before writing them results in undefined behavior”
    • etc.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have been told that we have to use a piece of software called
I was just told that I might have to work on a project where
I have been told that there is a performance difference between the following code
I have previously been told that I should always use Randomize() before I use
I am building a web application and have been told that using object oriented
I have noticed that cURL in PHP returns different data when told to output
I have a start and stop button. I was told that I must use
I have been told that Singletons are hard to test. http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/ http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/ I have
I have been told that the code <script> alert(java.lang.System.getProperty(java.version)); </script> should alert the java
I am told that the configuration below is possible, but have had significant difficulty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.