# Wrong return value for clCompileProgram

**URL:** <https://forums.developer.nvidia.com/t/wrong-return-value-for-clcompileprogram/247873>\
**Category:** CUDA Programming and Performance\
**Tags:** opencl, nvbugs\
**Created:** [March 29, 2023, 1:26am UTC](https://forums.developer.nvidia.com/t/wrong-return-value-for-clcompileprogram/247873 "2023-03-29T01:26:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvaro\_sch](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/alvaro_sch/32/238930_2.png) [@alvaro\_sch](https://forums.developer.nvidia.com/u/alvaro_sch)\
**Post date:** [March 29, 2023, 1:26am UTC](https://forums.developer.nvidia.com/t/wrong-return-value-for-clcompileprogram/247873/1 "2023-03-29T01:26:30Z")

</div>

I’m running on Arch Linux with `opencl-nvidia 530.41.03-1` drivers, I got `CL_BUILD_PROGRAM_FAILURE` instead of the documented `CL_COMPILE_PROGRAM_FAILURE` in the latest version of the [OpenCL spec](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#clCompileProgram).

Here’s a minimal code snippet + output showcasing that behavior.

```c
#include <stdio.h>
#include <stdlib.h>

#define CL_TARGET_OPENCL_VERSION 300
#include <CL/opencl.h>

const char *source = "invalid source code";

int main(void) {
    cl_platform_id platform;
    clGetPlatformIDs(1, &platform, NULL);

    char platform_version[50], platform_name[50], platform_vendor[50];
    clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 50 * sizeof(char), platform_version, NULL);
    clGetPlatformInfo(platform, CL_PLATFORM_VENDOR, 50 * sizeof(char), platform_vendor, NULL);
    clGetPlatformInfo(platform, CL_PLATFORM_NAME, 50 * sizeof(char), platform_name, NULL);

    printf(
        "platform info:\n"
        "\tname: %s\n"
        "\tvendor: %s\n"
        "\tversion: %s\n",
        platform_name, platform_vendor, platform_version
    );

    cl_device_id device;
    clGetDeviceIDs(platform, CL_DEVICE_TYPE_DEFAULT, 1, &device, NULL);

    cl_context context = clCreateContext(NULL, 1, &device, NULL, NULL, NULL);
    cl_command_queue queue = clCreateCommandQueueWithProperties(context, device, NULL, NULL);

    cl_program program = clCreateProgramWithSource(context, 1, &source, NULL, NULL);
    cl_int compile_status = clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL);

    printf(
        "CL_COMPILE_PROGRAM_FAILURE: %u\n"
        "CL_BUILD_PROGRAM_FAILURE: %u\n"
        "compile_status: %u\n",
        CL_COMPILE_PROGRAM_FAILURE, CL_BUILD_PROGRAM_FAILURE, compile_status
    );

    clReleaseProgram(program);
    clReleaseCommandQueue(queue);
    clReleaseContext(context);
}

```

Output:

```auto
λ ~ ls /etc/OpenCL/vendors
nvidia.icd
λ bug gcc src/main.c `pkg-config --libs OpenCL` && ./a.out
platform info:
	name: NVIDIA CUDA
	vendor: NVIDIA Corporation
	version: OpenCL 3.0 CUDA 12.1.98
2 errors generated.
CL_COMPILE_PROGRAM_FAILURE: 4294967281
CL_BUILD_PROGRAM_FAILURE: 4294967285
compile_status: 4294967285

```

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [March 29, 2023, 2:18pm UTC](https://forums.developer.nvidia.com/t/wrong-return-value-for-clcompileprogram/247873/2 "2023-03-29T14:18:31Z")

</div>

I suggest [filing a bug](https://forums.developer.nvidia.com/t/how-to-report-a-bug/67911).

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [April 12, 2023, 2:19pm UTC](https://forums.developer.nvidia.com/t/wrong-return-value-for-clcompileprogram/247873/3 "2023-04-12T14:19:17Z")

</div>

Closed on April 12, 2023, 2:19pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
