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

Won't compile in GCC 4.9.1 #8

Closed
ptsneves opened this issue Jan 13, 2015 · 8 comments
Closed

Won't compile in GCC 4.9.1 #8

ptsneves opened this issue Jan 13, 2015 · 8 comments

Comments

@ptsneves
Copy link

I have had this issue just including your header and compiling with GCC 4.9.1. My error log comes out like this:

concurrentqueue/concurrentqueue.h: In destructor ‘moodycamel::ConcurrentQueue<T, Traits>::ExplicitProducer::~ExplicitProducer()’:
concurrentqueue/concurrentqueue.h:1538:51: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp> struct std::is_empty’
  if (block->template is_empty<explicit_context>()) {
                                               ^
concurrentqueue/concurrentqueue.h:1538:51: error:   expected a type, got ‘explicit_context’
concurrentqueue/concurrentqueue.h: In member function ‘bool moodycamel::ConcurrentQueue<T, Traits>::ExplicitProducer::enqueue(U&&)’:
concurrentqueue/concurrentqueue.h:1586:96: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp> struct std::is_empty’
 if (this->tailBlock != nullptr && this->tailBlock->next->template is_empty<explicit_context>()) {
                                                                                        ^
concurrentqueue/concurrentqueue.h:1586:96: error:   expected a type, got ‘explicit_context’
concurrentqueue/concurrentqueue.h: In member function ‘bool moodycamel::ConcurrentQueue<T, Traits>::ExplicitProducer::enqueue_bulk(It, moodycamel::ConcurrentQueue<T, Traits>::size_t)’:
concurrentqueue/concurrentqueue.h:1791:168: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp> struct std::is_empty’
 while (blockBaseDiff > 0 && this->tailBlock != nullptr && this->tailBlock->next != firstAllocatedBlock && this->tailBlock->next->template is_empty<explicit_context>()) {
                                                                                                                                                                    ^
concurrentqueue/concurrentqueue.h:1791:168: error:   expected a type, got ‘explicit_context’
concurrentqueue/concurrentqueue.h: In destructor ‘moodycamel::ConcurrentQueue<T, Traits>::ExplicitProducer::~ExplicitProducer()’:
concurrentqueue/concurrentqueue.h:1538:51: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp> struct std::is_empty’
  if (block->template is_empty<explicit_context>()) {
                                               ^
concurrentqueue/concurrentqueue.h:1538:51: error:   expected a type, got ‘explicit_context’
concurrentqueue/concurrentqueue.h: In member function ‘bool moodycamel::ConcurrentQueue<T, Traits>::ExplicitProducer::enqueue(U&&)’:
concurrentqueue/concurrentqueue.h:1586:96: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp> struct std::is_empty’
 if (this->tailBlock != nullptr && this->tailBlock->next->template is_empty<explicit_context>()) {
                                                                                            ^
concurrentqueue/concurrentqueue.h:1586:96: error:   expected a type, got ‘explicit_context’
concurrentqueue/concurrentqueue.h: In member function ‘bool moodycamel::ConcurrentQueue<T, Traits>::ExplicitProducer::enqueue_bulk(It, moodycamel::ConcurrentQueue<T, Traits>::size_t)’:
concurrentqueue/concurrentqueue.h:1791:168: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp> struct std::is_empty’
 while (blockBaseDiff > 0 && this->tailBlock != nullptr && this->tailBlock->next != firstAllocatedBlock && this->tailBlock->next->template is_empty<explicit_context>()) {
                                                                                                                                                                    ^

Funny enough somebody has already tried to fix it just 3 days ago [gituhub]GATB/bcalm@be7bda8 so you might have a look at it.

Thanks for your work.

@cameron314
Copy link
Owner

Ahh! That's... not good. It thinks my Block::is_empty() is std::is_empty. I'll have to think about how I can force the correct interpretation... this doesn't happen with g++ 4.8.1. I'd rather not resort to the linked commit's workaround (which duplicates the function definition) since I have quite a bit of repetitive code already.

Thanks for opening this issue!

@cameron314
Copy link
Owner

You wouldn't happen to have a using namespace std; somewhere before the #include, would you? (It still shouldn't generate an error, mind, but it would at least make slightly more sense.)

@cameron314
Copy link
Owner

I've reduced the problem to this test case: http://stackoverflow.com/q/27930448/21475
Very weird.

@ptsneves
Copy link
Author

Sorry for the long delay, but I had some interruptions and I had to clean out my code of using namespace std; which I didn't even know was in a header I was including.

Your tip, was right. When I removed the using namespace std; no compile errors appeared. Thank you for avoiding a patch into a code I didn't really understand nor wanted to :D

@cameron314
Copy link
Owner

Great, I'm glad you're no longer blocked by this. It's looking more and more like a bug with g++. Fortunately, there's a simple workaround, which I'll try to commit soon.

@ptsneves
Copy link
Author

But with your code I was using namespace moodycamel in a cpp.

@cameron314
Copy link
Owner

That should be fine. Even combined with using namespace std, there shouldn't be clashes between names (unless the standard someday adds a class called ConcurrentQueue). It's either the compiler or my code (I don't think so, but we'll see) that's the problem.

@cameron314
Copy link
Owner

It's looking less like a bug in g++ (EDG generates an error too, but not Clang or VS), but definitely weird nonetheless. I've committed a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants