[Bug c++/97234] Constexpr class-scope array initializer referencing previous elements

2021-08-17 Thread botond at mozilla dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97234

Botond Ballo  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=99059

--- Comment #3 from Botond Ballo  ---
Bug 99059 is similar (involving C++17 "inline" rather than constexpr) and
Jonathan Wakely said it's a bug.

[Bug c++/97234] Constexpr class-scope array initializer referencing previous elements

2021-08-16 Thread botond at mozilla dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97234

--- Comment #2 from Botond Ballo  ---
I believe it's valid because the point of declaration of a variable is just
before its initializer
(https://timsong-cpp.github.io/cppwp/n4861/basic.scope.pdecl#1), and thus the
variable should be in scope in its initializer.

But I'm not a wording expert and it's possible I'm mistaken, or overlooking
something else that would make this invalid.

[Bug c++/100644] New: [11 regression] Deleted move constructor prevents templated constructor from being used

2021-05-17 Thread botond at mozilla dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100644

Bug ID: 100644
   Summary: [11 regression] Deleted move constructor prevents
templated constructor from being used
   Product: gcc
   Version: 11.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: botond at mozilla dot com
  Target Milestone: ---

GCC 11 gives an error for the following code which GCC 10 and Clang accept:


struct NonMovable {
  NonMovable(NonMovable&&) = delete;
};

template 
struct Maybe {
  NonMovable mMember;

  template 
  Maybe(Maybe&&);
};

void foo(Maybe);

void unlucky(Maybe&& x) {
  Maybe var{(Maybe&&)x};
}


The error is:


main.cpp: In function ‘void unlucky(Maybe&&)’:
main.cpp:16:33: error: use of deleted function
‘Maybe::Maybe(Maybe&&)’
   16 |   Maybe var{(Maybe&&)x};
  | ^
main.cpp:6:8: note: ‘Maybe::Maybe(Maybe&&)’ is implicitly deleted
because the default definition would be ill-formed:
6 | struct Maybe {
  |^
main.cpp:6:8: error: use of deleted function
‘NonMovable::NonMovable(NonMovable&&)’
main.cpp:2:3: note: declared here
2 |   NonMovable(NonMovable &&) = delete;
  |   ^~


I believe the code should be accepted, with the deleted move constructor
ignored during overload resolution and the templated constructor used instead.

I explain my reasoning, with links to the standard, in more detail here:
https://bugzilla.mozilla.org/show_bug.cgi?id=1710235#c22

Please let me know if I've overlooked something and the code really is invalid.

[Bug c++/97234] New: Constexpr class-scope array initializer referencing previous elements

2020-09-28 Thread botond at mozilla dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97234

Bug ID: 97234
   Summary: Constexpr class-scope array initializer referencing
previous elements
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: botond at mozilla dot com
  Target Milestone: ---

The following code:

struct S {
static constexpr int rolling_sum[4]{
0,
rolling_sum[0] + 1,
rolling_sum[1] + 2,
rolling_sum[2] + 3
};
};

produces errors when compiled with g++ 10:

test.cpp:4:9: error: ‘rolling_sum’ was not declared in this scope
4 | rolling_sum[0] + 1,
  | ^~~
test.cpp:5:9: error: ‘rolling_sum’ was not declared in this scope
5 | rolling_sum[1] + 2,
  | ^~~
test.cpp:6:9: error: ‘rolling_sum’ was not declared in this scope
6 | rolling_sum[2] + 3
  |   

The code is accepted by clang. It's also accepted by gcc if the array is
declared at namespace scope, leading me to believe that rejecting it at class
scope is likely a bug.

[Bug c++/65869] Incorrect overload resolution in function return statement

2015-04-24 Thread botond at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65869

--- Comment #2 from Botond Ballo botond at mozilla dot com ---
(In reply to Marc Glisse from comment #1)
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579

I don't think the resolution of this issue affects the validity of my code
example, i.e. it remains invalid.

The resolution of this issue makes the following code valid:

  Derived foo() {
Base result;
return result;
  }

(because it allows [class.copy] p32 to apply at all, where previously it didn't
apply because the type of the object to be copied, Base, was different from the
return type of the function Derived).

In my example, however:

  Derived foo() {
Derived result;
return result;
  }

p32 already applies, with or without the added wording. The problem is wording
further down in the paragraph which prevents the 'Derived(Base)' constructor
from being selected in the first overload resolution when the type of the
object is Derived.


[Bug c++/65869] Incorrect overload resolution in function return statement

2015-04-24 Thread botond at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65869

--- Comment #4 from Botond Ballo botond at mozilla dot com ---
   - The second overload resolution fails, because the only
 candidate (again, the explicit constructors are not
 candidates) has an rvalue reference parameter, which
 cannot bind to the lvalue that we're not treating the
 object as being.

This is also a typo, should say cannot bind to the lvalue that we're treating
the object as being.


[Bug c++/65869] New: Incorrect overload resolution in function return statement

2015-04-23 Thread botond at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65869

Bug ID: 65869
   Summary: Incorrect overload resolution in function return
statement
   Product: gcc
   Version: 4.9.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: botond at mozilla dot com

GCC accepts the following code:


struct Base {};

struct Derived : Base {
Derived();
explicit Derived(const Derived);
explicit Derived(Derived);
explicit Derived(const Base);
Derived(Base);
};

Derived foo() {
  Derived result;
  return result;
}

int main() {
  Derived result = foo();
}


I believe this code is invalid. Here's why:

  - [class.copy] p32 specifies that overload resolution
to select the constructor for the copy in the return
statement is to be performed in two stages.

  - First, it's performed treating the object to be copied
('result' here) as an rvalue.

  - Here, the 'Derived(Base)' constructor is selected.
(The explicit constructors are not candidates in this
context.)

  - However, p32 says that if the type of the first
parameter of the selected constructor is not an rvalue
reference to the object's type, then overload 
resolution is performed again, treating the object as 
an rvalue.

  - Here, the type of the first parameter of the
selected constructor is 'Base'. This is an rvalue
reference, but it's not to the object's type
(the object's type being 'Derived'). Therefore,
this provision is activated.

  - The second overload resolution fails, because the only
candidate (again, the explicit constructors are not
candidates) has an rvalue reference parameter, which
cannot bind to the lvalue that we're not treating the
object as being.

A more detailed and better-formatted explanation can be found here [1].

Clang rejects this code, showing the error from the failure
of the second overload resolution:

test.cpp:13:10: error: no matching constructor for initialization of 'Derived'
  return result;
 ^~
test.cpp:8:5: note: candidate constructor not viable: no known conversion from
'Derived' to 'Base ' for 1st argument
Derived(Base);
^
test.cpp:4:5: note: candidate constructor not viable: requires 0 arguments, but
1 was provided
Derived();
^

[1] http://stackoverflow.com/a/29834426/141719


[Bug c++/61959] New: internal compiler error: Segmentation fault when building Mozilla code

2014-07-29 Thread botond at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61959

Bug ID: 61959
   Summary: internal compiler error: Segmentation fault when
building Mozilla code
   Product: gcc
   Version: 4.7.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: botond at mozilla dot com

Created attachment 33208
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=33208action=edit
preprocessed source, zipped

I ran into an internal compiler error while trying to compile the Gecko
codebase with the patch at [1].

The output was:

/home/botond/dev/mozilla/refactoring/dom/events/EventStateManager.cpp:5609:1:
internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See file:///usr/share/doc/gcc-4.7/README.Bugs for instructions.
Preprocessed source stored into /tmp/cc7rD5Nc.out file, please attach this to
your bugreport.

Attached is the preprocessed source; I had to zip it to stay within the
attachment size limit.

My GCC version is 4.7.3; OS is Linux Mint 15 (Olivia).

Please let me know if there is any further informative I can provide.

[1] https://bug923512.bugzilla.mozilla.org/attachment.cgi?id=8464279


[Bug c++/61959] internal compiler error: Segmentation fault when building Mozilla code

2014-07-29 Thread botond at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61959

--- Comment #2 from Botond Ballo botond at mozilla dot com ---
(In reply to Andrew Pinski from comment #1)
 See file:///usr/share/doc/gcc-4.7/README.Bugs for instructions.

Here is the output of g++ -v:

Using built-in specs.
COLLECT_GCC=/usr/bin/g++-4.7.real
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.7.3-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl
--disable-cloog-version-check --disable-ppl-version-check --enable-multiarch
--disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)

Here is the complete command that triggers the bug:

  g++ -c -std=c++11 esm-ice.ii

Anything else I missed?


[Bug c++/61959] internal compiler error: Segmentation fault when building Mozilla code

2014-07-29 Thread botond at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61959

Botond Ballo botond at mozilla dot com changed:

   What|Removed |Added

Version|4.7.3   |4.9.0

--- Comment #3 from Botond Ballo botond at mozilla dot com ---
Tried this with 4.9.0. I still get an ICE, but the error message is more
informative now:

/home/botond/dev/mozilla/refactoring/dom/events/EventStateManager.cpp:5609:1:
internal compiler error: in tree_to_uhwi, at tree.h:3657
0xb22aab tree_to_uhwi
../../src/gcc/tree.h:3657
0xb22aab output_constructor_regular_field
../../src/gcc/varasm.c:4894
0xb22aab output_constructor
../../src/gcc/varasm.c:5231
0xb21c7e assemble_variable(tree_node*, int, int, int)
../../src/gcc/varasm.c:2139
0xb238a5 varpool_assemble_decl(varpool_node*)
../../src/gcc/varpool.c:455
0x6de59d output_in_order
../../src/gcc/cgraphunit.c:2010
0x6de59d compile()
../../src/gcc/cgraphunit.c:2247
0x6de864 finalize_compilation_unit()
../../src/gcc/cgraphunit.c:2329
0x593f1b cp_write_global_declarations()
../../src/gcc/cp/decl2.c:4611


[Bug c++/61959] internal compiler error: in tree_to_uhwi, at tree.h:3657 when building Mozilla code

2014-07-29 Thread botond at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61959

--- Comment #4 from Botond Ballo botond at mozilla dot com ---
Reduced code that triggers the ICE:


template class T, class Sub, class Coord
struct BasePoint {
  Coord x, y;

  constexpr BasePoint(Coord aX, Coord aY) : x(aX), y(aY) {}
};

template class T, class Sub
struct BaseCoord {
  T value;

  explicit constexpr BaseCoord(T aValue) : value(aValue) {}
};

templateclass units
struct IntCoordTyped :
  public BaseCoord int, IntCoordTypedunits ,
  public units {

  typedef BaseCoord int, IntCoordTypedunits  Super;

  constexpr IntCoordTyped(int aValue) : Super(aValue) {}
};

templateclass units
struct IntPointTyped :
  public BasePoint int, IntPointTypedunits, IntCoordTypedunits ,
  public units {

  typedef IntCoordTypedunits Coord;
  typedef BasePoint int, IntPointTypedunits, IntCoordTypedunits  Super;

  constexpr IntPointTyped(int aX, int aY) : Super(Coord(aX), Coord(aY)) {}
};

struct LayoutDevicePixel {};
typedef IntPointTypedLayoutDevicePixel LayoutDeviceIntPoint;

static const LayoutDeviceIntPoint kInvalidRefPoint =
LayoutDeviceIntPoint(-1,-1);