[Bug c++/30277] bit-field: wrong overload resolution
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277 Jason Merrill changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED Target Milestone|--- |10.0 --- Comment #10 from Jason Merrill --- Fixed for GCC 10.
[Bug c++/30277] bit-field: wrong overload resolution
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277 --- Comment #9 from Jakub Jelinek --- Author: jakub Date: Sat Sep 21 21:54:38 2019 New Revision: 276021 URL: https://gcc.gnu.org/viewcvs?rev=276021=gcc=rev Log: PR c++/30277 * g++.dg/expr/bitfield14.C (struct S): Use signed long long instead of signed long. (foo): Use long long instead of long. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/expr/bitfield14.C
[Bug c++/30277] bit-field: wrong overload resolution
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277 John David Anglin changed: What|Removed |Added CC||danglin at gcc dot gnu.org --- Comment #8 from John David Anglin --- Also seen on hppa-unknown-linux-gnu.
[Bug c++/30277] bit-field: wrong overload resolution
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277 Rainer Orth changed: What|Removed |Added CC||ro at gcc dot gnu.org --- Comment #7 from Rainer Orth --- The new testcase FAILs on 32-bit targets (seen on i386-pc-solaris2.11 and sparc-sun-solaris2.11, and many more on gcc-testresults): +FAIL: g++.dg/expr/bitfield14.C -std=c++14 (test for excess errors) +FAIL: g++.dg/expr/bitfield14.C -std=c++17 (test for excess errors) Excess errors: /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/expr/bitfield14.C:15:12: error: use of deleted function 'void foo(long int)'
[Bug c++/30277] bit-field: wrong overload resolution
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277 --- Comment #6 from Jason Merrill --- Author: jason Date: Mon Sep 16 04:34:28 2019 New Revision: 275746 URL: https://gcc.gnu.org/viewcvs?rev=275746=gcc=rev Log: PR c++/30277 - int-width bit-field promotion. Here, if cp_perform_integral_promotions saw that the TREE_TYPE of a bit-field reference was the same as the type it promotes to, it didn't do anything. But then decay_conversion saw that the bit-field reference was unchanged, and converted it to its declared type. So I needed to add something to make it clear that promotion has been done. But then the 33819 change caused trouble by looking through the NOP_EXPR I just added. This was the wrong fix for that bug; I've now fixed that better by recognizing in cp_perform_integral_promotions that we won't promote a bit-field larger than 32 bits, so we should use the declared type. PR c++/33819 - long bit-field promotion. * typeck.c (cp_perform_integral_promotions): Handle large bit-fields properly. Handle 32-bit non-int bit-fields properly. (is_bitfield_expr_with_lowered_type): Don't look through NOP_EXPR. Added: trunk/gcc/testsuite/g++.dg/expr/bitfield14.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck.c
[Bug c++/30277] bit-field: wrong overload resolution
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277 Jason Merrill changed: What|Removed |Added Status|NEW |ASSIGNED CC||jason at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
[Bug c++/30277] bit-field: wrong overload resolution
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277 nicbrown changed: What|Removed |Added CC||contacts at buymore dot pro --- Comment #5 from nicbrown --- In C++03, integral promotions for bit-fields are specified in 4.5 https://tinyurl.com/y39m4st6
[Bug c++/30277] bit-field: wrong overload resolution
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277 --- Comment #4 from Tom Honermann --- We recently got bit by this. It is still an issue in latest gcc trunk: $ cat t.cpp enum E : int { e1 = 1 }; constexpr E operator-(E, E) { return (E)99; } typedef struct { E e; E ebf : 16; } S; constexpr S s = { e1, e1 }; static_assert(99 == (int)(s.e-s.e),"Overload resolution failed for non-bit-field"); static_assert(99 == (int)(s.ebf-s.ebf),"Overload resolution failed for bit-field"); $ g++ --version g++ (GCC) 7.0.0 20160721 (experimental) ... $ g++ -c -std=c++11 t.cpp t.cpp:9:14: warning: â::ebfâ is too small to hold all values of âenum Eâ E ebf : 16; ^~ t.cpp:13:1: error: static assertion failed: Overload resolution failed for bit-field static_assert(99 == (int)(s.ebf-s.ebf),"Overload resolution failed for bit-field"); ^ (I would love to be able to disable that warning as well: bug 51242)
[Bug c++/30277] bit-field: wrong overload resolution
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277 Paolo Carlini paolo.carlini at oracle dot com changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2015-03-25 CC|gcc-bugs at gcc dot gnu.org| Ever confirmed|0 |1
[Bug c++/30277] bit-field: wrong overload resolution
--- Comment #3 from s__nakayama at infoseek dot jp 2007-01-22 18:28 --- (In reply to comment #1) I only have the C99 standard, and there I read in 6.3.1.1 p2 that only those variables are promoted to int that are of smaller size. Similarly, in 6.3.1.8, integer promotion rules are specified, and they specify that types in binary operations are always converted to the type with the greater range. In your case, this would be signed long. Do you disagree with this rationale? C++03 4.5 p3 | An rvalue for an integral bit-field (9.6) can be converted | to an rvalue of type int if int can represent all the values ^^^ | of the bit-field; otherwise, it can be converted to unsigned | int if unsigned int can represent all the values of the | bit-field. If the bit-field is larger yet, no integral promotion | applies to it. If the bit-field has an enumerated type, it is | treated as any other value of that type for promotion purposes. 32bit bit-fields and int has the same range of value. The bit-field shall be converted to int, because int can represent all the values of 32bit bit-fields. -- s__nakayama at infoseek dot jp changed: What|Removed |Added Status|WAITING |UNCONFIRMED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277
[Bug c++/30277] bit-field: wrong overload resolution
--- Comment #2 from joseph at codesourcery dot com 2007-01-21 12:28 --- Subject: Re: bit-field: wrong overload resolution On Sun, 21 Jan 2007, bangerth at dealii dot org wrote: I only have the C99 standard, and there I read in 6.3.1.1 p2 that only those variables are promoted to int that are of smaller size. C and C++ handle bit-fields differently. C99 text about bit-fields is irrelevant and misleading for C++. In C++03, integral promotions for bit-fields are specified in 4.5 [conv.prom] (note these are can be converted, as part of a conversion sequence; the underlying concepts are not those of C), and before any such conversion a C++ bit-field has the declared type as per 9.6 [class.bit] rather than a special type as in C. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277
[Bug c++/30277] bit-field: wrong overload resolution
--- Comment #1 from bangerth at dealii dot org 2007-01-21 05:16 --- I only have the C99 standard, and there I read in 6.3.1.1 p2 that only those variables are promoted to int that are of smaller size. Similarly, in 6.3.1.8, integer promotion rules are specified, and they specify that types in binary operations are always converted to the type with the greater range. In your case, this would be signed long. Do you disagree with this rationale? Best Wolfgang -- bangerth at dealii dot org changed: What|Removed |Added CC||bangerth at dealii dot org Status|UNCONFIRMED |WAITING http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277