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

gcc 5.2.1/6.1.1: error: inconsistent operand constraints in an ‘asm’ #213

Closed
zabereer opened this issue May 17, 2016 · 6 comments
Closed

Comments

@zabereer
Copy link

Compilation fails when using benchmark::DoNotOptimize on an array:

In file included from benchmark/include/benchmark/benchmark.h:18:0, from bm_boost_crc.cpp:1: benchmark/include/benchmark/benchmark_api.h: In function ‘void {anonymous}::boost_crc6(benchmark::State&)’: benchmark/include/benchmark/benchmark_api.h:217:54: error: inconsistent operand constraints in an ‘asm’ asm volatile("" : "+rm" (const_cast<Tp&>(value)));

Although gcc documenation on asm contraints indicates they should be adjacent I find inserting a comma ("+r,m") solves this problem. However it then does not work for functions returning an integral like boost::crc_optimal's checksum method:

value_type checksum() const;

I find the best solution to both is to use a template for pointers separately.
I have a patch that seem to work in all cases I have encountered so far.

@EricWF
Copy link
Contributor

EricWF commented May 17, 2016

Urg. so the "rm" used to mean put this value in a register if possible, otherwise put it in memory. I think there's another way to say this that will avoid the conflicting constraints error.

@EricWF
Copy link
Contributor

EricWF commented May 17, 2016

I cannot reproduce the error your seeing with GCC. (See https://goo.gl/krlgJM).

Could you please try changing "+rm" to "+g" and tell me if that works?

@EricWF
Copy link
Contributor

EricWF commented May 17, 2016

OK so I managed to reproduce here: https://goo.gl/CJqGjJ. Unfortunately the change to "+g" doesn't work. Versions of GCC prior to v5 ICE on this code. Changing "+rm" to "+g" still emits the same error. I'll file a GCC bug since "+g" shouldn't have any conflicting constraints since its obviously a single constraint.

@zabereer
Copy link
Author

In hindsight I realise it is wrong to try to force a memory constraint on all non-pointer types.
Many thanks for filing the gcc bug, that is kind of you.

@EricWF
Copy link
Contributor

EricWF commented May 23, 2016

@EricWF
Copy link
Contributor

EricWF commented Jul 1, 2016

I think this has been fixed in master. Please reopen if I'm incorrect.

@EricWF EricWF closed this as completed Jul 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants