Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expansion pattern 'CompatibleObjectType' contains no argument packs, with CUDA 10 #1347

Closed
carlosgalvezp opened this issue Nov 9, 2018 · 9 comments
Labels
state: help needed the issue needs help to proceed state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated

Comments

@carlosgalvezp
Copy link

Hi,

I'm using your JSON library in my code. I have a pretty old version (2.1) and would like to upgrade to 3.4.0. However the CUDA 10 compiler seems to have errors when trying to get data as a vectors. With the GCC compiler (5.4) it compiles fine.
I attach example code from this issue, where the issue was solved:

#include <iostream>

#include "json.hpp"

using nlohmann::json;

int main()
{
    auto j = R"(
    {
         "names": ["Tim", "Tom"],
         "num": [1.2, 2.3]
    }
    )"_json;

    std::vector<std::string> names = j["names"];

    for (auto i : names)
    {
        std::cout << i << " ";
    }

    // prints: Tim Tom 
}

This gives the following compilation errors:

$ nvcc -isystem include -std=c++14 main.cu 

include/json.hpp:552:151: error: expansion pattern 'CompatibleObjectType' contains no argument packs
include/json.hpp:552:154: error: template argument 4 is invalid
include/json.hpp:552:261: error: template argument 1 is invalid
include/json.hpp:552:263: error: template argument 3 is invalid
include/json.hpp:577:160: error: expansion pattern 'ConstructibleObjectType' contains no argument packs
include/json.hpp:577:163: error: template argument 4 is invalid
include/json.hpp:577:273: error: template argument 1 is invalid
include/json.hpp:577:275: error: template argument 3 is invalid
include/json.hpp:637:147: error: expansion pattern 'CompatibleArrayType' contains no argument packs
include/json.hpp:637:150: error: template argument 4 is invalid
include/json.hpp:637:335: error: template argument 1 is invalid
include/json.hpp:637:337: error: template argument 3 is invalid
include/json.hpp:667:244: error: expansion pattern 'ConstructibleArrayType' contains no argument packs
include/json.hpp:667:247: error: template argument 4 is invalid
include/json.hpp:667:81: error: parse error in template argument list
main.cu: In function 'int main()':
main.cu:16:118: error: conversion from 'nlohmann::basic_json<>::value_type {aka nlohmann::basic_json<>}' to non-scalar type 'std::vector<std::__cxx11::basic_string<char> >' requested

Using the get<std::vector<std::string>> method gives even more errors on top of the previous ones.

Have you seen this error before?

Thanks!

@carlosgalvezp carlosgalvezp changed the title expansion pattern 'CompatibleObjectType' contains to argument packs, with CUDA 10 expansion pattern 'CompatibleObjectType' contains no argument packs, with CUDA 10 Nov 9, 2018
@nlohmann
Copy link
Owner

Thanks for reporting! I have not seen this before, but maybe someone has an idea.

@stale
Copy link

stale bot commented Dec 11, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Dec 11, 2018
@stale stale bot closed this as completed Dec 19, 2018
@thoangtrvn
Copy link

I have the same issue with nvcc 10.0, compile with -std=c+=11

@cliffburdick
Copy link

Same issue with CUDA 10.1 with std=c++14

@kemalfidan
Copy link

Also running into this problem with CUDA 10.1 and c++ 11

@dean-shaff
Copy link

I've run into the same problem with CUDA 10.1, g++ 6.4.0, c++11.

@darrelpalke
Copy link

Having the same issue here. It's possible that this is related to a bug similar to this:
https://stackoverflow.com/questions/43380550/which-compiler-if-any-has-a-bug-in-parameter-pack-expansion

I'm not entirely sure what c compiler NVCC uses or if they have their own and have the same bug.

I was able to work around this issue by not putting any json.hpp code into .cu files. The project I'm working with uses VS to compile the cpp files and NVCC to compile the .cu files so perhaps this isn't feasible for everyone else.

I was also able to get around this by commenting out a lot of the vector/string code in the json.hpp header but then of course you can't read either data type, which wasn't workable for me.

@b-v
Copy link

b-v commented Nov 21, 2019

I'm also have the same problem for the latest version, but it does work with CUDA 10.1 when I use version 3.2.0 of this JSON library (so newer than version 2.1 from the OP).

@nlohmann
Copy link
Owner

#1773 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: help needed the issue needs help to proceed state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated
Projects
None yet
Development

No branches or pull requests

8 participants