[Bug c++/60689] Bogus error with atomic::exchange
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60689 --- Comment #6 from Jakub Jelinek jakub at gcc dot gnu.org --- Author: jakub Date: Thu Apr 10 07:54:08 2014 New Revision: 209267 URL: http://gcc.gnu.org/viewcvs?rev=209267root=gccview=rev Log: Backport from mainline 2014-03-28 Jakub Jelinek ja...@redhat.com PR c++/60689 * c-tree.h (c_build_function_call_vec): New prototype. * c-typeck.c (build_function_call_vec): Don't call resolve_overloaded_builtin here. (c_build_function_call_vec): New wrapper function around build_function_call_vec. Call resolve_overloaded_builtin here. (convert_lvalue_to_rvalue, build_function_call, build_atomic_assign): Call c_build_function_call_vec instead of build_function_call_vec. * c-parser.c (c_parser_postfix_expression_after_primary): Likewise. * c-decl.c (finish_decl): Likewise. * c-common.c (add_atomic_size_parameter): When creating new params vector, push the size argument first. * c-c++-common/pr60689.c: New test. Added: branches/gcc-4_8-branch/gcc/testsuite/c-c++-common/pr60689.c Modified: branches/gcc-4_8-branch/gcc/c-family/ChangeLog branches/gcc-4_8-branch/gcc/c-family/c-common.c branches/gcc-4_8-branch/gcc/c/ChangeLog branches/gcc-4_8-branch/gcc/c/c-decl.c branches/gcc-4_8-branch/gcc/c/c-parser.c branches/gcc-4_8-branch/gcc/c/c-tree.h branches/gcc-4_8-branch/gcc/c/c-typeck.c branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
[Bug c++/60689] Bogus error with atomic::exchange
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60689 Jakub Jelinek jakub at gcc dot gnu.org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #7 from Jakub Jelinek jakub at gcc dot gnu.org --- Fixed.
[Bug c++/60689] Bogus error with atomic::exchange
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60689 Jakub Jelinek jakub at gcc dot gnu.org changed: What|Removed |Added Attachment #32469|0 |1 is obsolete|| --- Comment #4 from Jakub Jelinek jakub at gcc dot gnu.org --- Created attachment 32470 -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=32470action=edit gcc49-pr60689.patch Ugh, except it doesn't work, it breaks C. The problem is that add_atomic_size_parameter calls build_function_call_vec which behaves differently between C and C++. For C that function calls resolve_overloaded_builtin, thus it recurses and adds the needed parameter in there and if we add the extra parameter as in my earlier patch, the recursive resolve_overloaded_builtin will complain that __atomic_exchange has too many parameters. For C++ it doesn't call that (finish_call_expr calls that instead), thus if we don't add the parameter there, nothing adds it. So, the options I see are: 1) what I'm attaching, make build_function_call_vec which is in C++ FE only called from c-common/ bits behave like C build_function_call_vec and call resolve_overloaded_builtin there 2) some static flag which will do nothing in resolve_overloaded_builtin if called recursively (but, David Malcolm will complain about global state) 3) when checking number of arguments, allow the case when there is the extra integer argument for the size; the problem with that is that I'd be afraid we'd allow people that way to call __atomic_exchange (9, ptr1, ptr2, ptr3, __ATOMIC_SEQ_CST); which we don't want to
[Bug c++/60689] Bogus error with atomic::exchange
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60689 --- Comment #5 from Jakub Jelinek jakub at gcc dot gnu.org --- Author: jakub Date: Fri Mar 28 18:16:32 2014 New Revision: 208912 URL: http://gcc.gnu.org/viewcvs?rev=208912root=gccview=rev Log: PR c++/60689 * c-tree.h (c_build_function_call_vec): New prototype. * c-typeck.c (build_function_call_vec): Don't call resolve_overloaded_builtin here. (c_build_function_call_vec): New wrapper function around build_function_call_vec. Call resolve_overloaded_builtin here. (convert_lvalue_to_rvalue, build_function_call, build_atomic_assign): Call c_build_function_call_vec instead of build_function_call_vec. * c-parser.c (c_parser_postfix_expression_after_primary): Likewise. * c-decl.c (finish_decl): Likewise. * c-common.c (add_atomic_size_parameter): When creating new params vector, push the size argument first. * c-c++-common/pr60689.c: New test. Added: trunk/gcc/testsuite/c-c++-common/pr60689.c Modified: trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-common.c trunk/gcc/c/ChangeLog trunk/gcc/c/c-decl.c trunk/gcc/c/c-parser.c trunk/gcc/c/c-tree.h trunk/gcc/c/c-typeck.c trunk/gcc/testsuite/ChangeLog
[Bug c++/60689] Bogus error with atomic::exchange
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60689 Jonathan Wakely redi at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2014-03-27 CC||rth at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely redi at gcc dot gnu.org --- #ifndef N #define N 9 #endif struct S { char a[N]; }; int main() { S a, b, c; __atomic_exchange(a, b, c, __ATOMIC_SEQ_CST); } $ g++ -std=c++11 aa.cc -DN=8 $ g++ -std=c++11 aa.cc aa.cc: In function ‘int main()’: aa.cc:10:49: error: invalid conversion from ‘S*’ to ‘long unsigned int’ [-fpermissive] __atomic_exchange(a, b, c, __ATOMIC_SEQ_CST); ^ aa.cc:10:49: error: invalid conversion from ‘int’ to ‘void*’ [-fpermissive] aa.cc:10:49: error: too few arguments to function ‘void __atomic_exchange(long unsigned int, volatile void*, void*, void*, int)’ built-in: note: declared here
[Bug c++/60689] Bogus error with atomic::exchange
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60689 --- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org --- when the object is bigger than the wordsize the generic __atomic_exchange gets expanded incorrectly $ g++11 aa.cc -DN=4 -m32 $ g++11 aa.cc -DN=5 -m32 aa.cc: In function ‘int main()’: aa.cc:10:49: error: invalid conversion from ‘S*’ to ‘unsigned int’ [-fpermissive] __atomic_exchange(a, b, c, __ATOMIC_SEQ_CST); ^ aa.cc:10:49: error: invalid conversion from ‘int’ to ‘void*’ [-fpermissive] aa.cc:10:49: error: too few arguments to function ‘void __atomic_exchange(unsigned int, volatile void*, void*, void*, int)’ built-in: note: declared here
[Bug c++/60689] Bogus error with atomic::exchange
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60689 Jakub Jelinek jakub at gcc dot gnu.org changed: What|Removed |Added Status|NEW |ASSIGNED CC||jakub at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek jakub at gcc dot gnu.org --- Created attachment 32469 -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=32469action=edit gcc49-pr60689.patch Untested fix. 4.8 needs the same fix I think. In any case, no idea where to put a test for this. libstdc++-v3? libatomic? g++.dg and just make it compile test?