title: Opencl Segmentation fault while accessing device info
body: <p>I'm a newbie in OpenCL programming.
  My very first program is giving me a hard time. I wanted to query device name and vendor name of every device in each platform. My system has two platforms, the first one is AMD platform and the second is NVIDIA CUDA platform. I've written the following code to get the desired info.</p>
  
  <pre><code> int main(int argc, char **argv) {
  
      try {
              vector&lt;cl::Platform&gt;platforms;
              cl::Platform::get(&amp;platforms);
  
              cl_context_properties properties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(), 0}; 
              cl::Context context(CL_DEVICE_TYPE_ALL, properties);
  
              vector&lt;cl::Device&gt; devices = context.getInfo&lt;CL_CONTEXT_DEVICES&gt;();
  
              string dName(devices[0].getInfo&lt;CL_DEVICE_NAME&gt;());
              string vendor(devices[0].getInfo&lt;CL_DEVICE_VENDOR&gt;());
  
              cout&lt;&lt;"\tDevice Name:"&lt;&lt;dName&lt;&lt;endl;
              cout&lt;&lt;"\tDevice Vendor: "&lt;&lt;vendor&lt;&lt;endl;    
      }catch(cl::Error  err) {
              cerr&lt;&lt;err.what()&lt;&lt;" error: "&lt;&lt;printErrorString(err.err())&lt;&lt;endl;
  
              return 0;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>when I change the platform index to 1 in</p>
  
  <pre><code>    cl_context_properties properties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(), 0}; 
  </code></pre>
  
  <p>my program crashes with 'Segmentation fault'.</p>
  
  <p>I really appreciate your help.
  Thanks!</p>