public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60258] New: Member initialization for atomic fail.
@ 2014-02-18  8:08 ja.gcc.bugzilla at aptsketch dot com
  2014-02-18  9:04 ` [Bug c++/60258] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ja.gcc.bugzilla at aptsketch dot com @ 2014-02-18  8:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60258

            Bug ID: 60258
           Summary: Member initialization for atomic fail.
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ja.gcc.bugzilla at aptsketch dot com

The following code is unable to compile:

template <class Ty1>
class base
{
public:
    std::atomic_size_t _magic{10};
};

class derived
    : public base<derived>
{
public:
    auto print_magic_num() const noexcept -> void
    {
    }
};

auto my_func() -> void
{
    derived a;
}

Removing the member initialization for the atomic will allow it to compile.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60258] Member initialization for atomic fail.
  2014-02-18  8:08 [Bug c++/60258] New: Member initialization for atomic fail ja.gcc.bugzilla at aptsketch dot com
@ 2014-02-18  9:04 ` jakub at gcc dot gnu.org
  2014-02-18 11:30 ` ja.gcc.bugzilla at aptsketch dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-02-18  9:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60258

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Why the
auto my_func() -> void
rather than
void my_func()
?  The fact that C++11 allows the former form doesn't mean the latter form is
deprecated, and in the case when the return type doesn't depend on argument
types it doesn't make any sense to use that form.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60258] Member initialization for atomic fail.
  2014-02-18  8:08 [Bug c++/60258] New: Member initialization for atomic fail ja.gcc.bugzilla at aptsketch dot com
  2014-02-18  9:04 ` [Bug c++/60258] " jakub at gcc dot gnu.org
@ 2014-02-18 11:30 ` ja.gcc.bugzilla at aptsketch dot com
  2014-02-18 11:34 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ja.gcc.bugzilla at aptsketch dot com @ 2014-02-18 11:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60258

--- Comment #2 from ja.gcc.bugzilla at aptsketch dot com ---
auto foo() -> void
vs
void foo()

is more of just a stylistic issue. There is nothing wrong with both. To me both
are good.

The bug is about std::atomic member initialization. Where if there is member
initialization std::atomic_size_t x{10} the compiler chokes on it.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60258] Member initialization for atomic fail.
  2014-02-18  8:08 [Bug c++/60258] New: Member initialization for atomic fail ja.gcc.bugzilla at aptsketch dot com
  2014-02-18  9:04 ` [Bug c++/60258] " jakub at gcc dot gnu.org
  2014-02-18 11:30 ` ja.gcc.bugzilla at aptsketch dot com
@ 2014-02-18 11:34 ` jakub at gcc dot gnu.org
  2014-02-18 20:06 ` daniel.kruegler at googlemail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-02-18 11:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60258

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Sure, my comment was about this stylistic issue, not about the real bug (if
any, haven't tried it).  Note your testcase isn't self-contained, you probably
need #include <atomic>.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60258] Member initialization for atomic fail.
  2014-02-18  8:08 [Bug c++/60258] New: Member initialization for atomic fail ja.gcc.bugzilla at aptsketch dot com
                   ` (2 preceding siblings ...)
  2014-02-18 11:34 ` jakub at gcc dot gnu.org
@ 2014-02-18 20:06 ` daniel.kruegler at googlemail dot com
  2014-02-19  7:58 ` daniel.kruegler at googlemail dot com
  2014-11-18 16:20 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-02-18 20:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60258

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #4 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
Reduced example:

//------------------
#include <atomic>

template <class>
struct base
{
  std::atomic_bool magic{false};
};

int main() 
{
  base<void> b;
}
//------------------

Diagnostics (gcc HEAD 4.9.0 20140215 (experimental)):

<quote>
prog.cc: In constructor 'constexpr base<void>::base()': 
prog.cc:4:8: error: use of deleted function
'std::atomic_bool::atomic_bool(const std::atomic_bool&)' 
  struct base 
         ^ 
In file included from prog.cc:1:0: 
/usr/local/gcc-head/include/c++/4.9.0/atomic:62:5: note: declared here
  atomic_bool(const atomic_bool&) = delete; 
  ^ 
prog.cc: In function 'int main()': 
prog.cc:11:14: note: synthesized method 'constexpr base<void>::base()' first
required here 
  base<void> b; 
  ^
</quote>

The error doesn't occur, if the class template is replaced by a non-template
class.
>From gcc-bugs-return-444122-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Feb 18 20:16:12 2014
Return-Path: <gcc-bugs-return-444122-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 29561 invoked by alias); 18 Feb 2014 20:16:11 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 29518 invoked by uid 48); 18 Feb 2014 20:16:06 -0000
From: "janus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/60232] [OOP] The rank of the element in the structure constructor does not match that of the component
Date: Tue, 18 Feb 2014 20:16:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: rejects-valid
X-Bugzilla-Severity: major
X-Bugzilla-Who: janus at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: janus at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status assigned_to
Message-ID: <bug-60232-4-sANny8WdBj@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60232-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60232-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg01879.txt.bz2
Content-length: 1918

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`232

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |janus at gcc dot gnu.org

--- Comment #2 from janus at gcc dot gnu.org ---
This patch fixes the error:


Index: gcc/fortran/resolve.c
==================================================================--- gcc/fortran/resolve.c    (revision 207846)
+++ gcc/fortran/resolve.c    (working copy)
@@ -1134,8 +1134,6 @@ resolve_structure_cons (gfc_expr *expr, int init)

   for (; comp && cons; comp = comp->next, cons = gfc_constructor_next (cons))
     {
-      int rank;
-
       if (!cons->expr)
     continue;

@@ -1145,15 +1143,18 @@ resolve_structure_cons (gfc_expr *expr, int init)
       continue;
     }

-      rank = comp->as ? comp->as->rank : 0;
-      if (cons->expr->expr_type != EXPR_NULL && rank != cons->expr->rank
-      && (comp->attr.allocatable || cons->expr->rank))
+      if (!comp->attr.proc_pointer)
     {
-      gfc_error ("The rank of the element in the structure "
-             "constructor at %L does not match that of the "
-             "component (%d/%d)", &cons->expr->where,
-             cons->expr->rank, rank);
-      t = false;
+      int rank = comp->as ? comp->as->rank : 0;
+      if (cons->expr->expr_type != EXPR_NULL && rank != cons->expr->rank
+          && (comp->attr.allocatable || cons->expr->rank))
+        {
+          gfc_error ("The rank of the element in the structure "
+            "constructor at %L does not match that of the "
+            "component (%d/%d)", &cons->expr->where,
+            cons->expr->rank, rank);
+          t = false;
+        }
     }

       /* If we don't have the right type, try to convert it.  */


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60258] Member initialization for atomic fail.
  2014-02-18  8:08 [Bug c++/60258] New: Member initialization for atomic fail ja.gcc.bugzilla at aptsketch dot com
                   ` (3 preceding siblings ...)
  2014-02-18 20:06 ` daniel.kruegler at googlemail dot com
@ 2014-02-19  7:58 ` daniel.kruegler at googlemail dot com
  2014-11-18 16:20 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-02-19  7:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60258

--- Comment #5 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Daniel Krügler from comment #4)
> Reduced example:

More reduced by eliminating library dependencies:

//------------------
struct atomic_bool
{
  atomic_bool(const atomic_bool&) = delete;
  constexpr atomic_bool(bool) noexcept { }
};

#define USE_TEMPLATE

#ifdef USE_TEMPLATE
template <class>
#endif
struct base
{
  atomic_bool magic{false};
};

int main()
{
#ifdef USE_TEMPLATE
  base<void> b;
#else
  base b;
#endif
}
//------------------
>From gcc-bugs-return-444169-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Feb 19 08:10:52 2014
Return-Path: <gcc-bugs-return-444169-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26364 invoked by alias); 19 Feb 2014 08:10:52 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 26326 invoked by uid 48); 19 Feb 2014 08:10:47 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60258] Member initialization for atomic fail.
Date: Wed, 19 Feb 2014 08:10:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords: rejects-valid
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-60258-4-CvQvrFjkPc@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60258-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60258-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg01926.txt.bz2
Content-length: 400

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`258

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-02-19
     Ever confirmed|0                           |1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/60258] Member initialization for atomic fail.
  2014-02-18  8:08 [Bug c++/60258] New: Member initialization for atomic fail ja.gcc.bugzilla at aptsketch dot com
                   ` (4 preceding siblings ...)
  2014-02-19  7:58 ` daniel.kruegler at googlemail dot com
@ 2014-11-18 16:20 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-18 16:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60258

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Dup, already fixed.

*** This bug has been marked as a duplicate of bug 58930 ***


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-18 16:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-18  8:08 [Bug c++/60258] New: Member initialization for atomic fail ja.gcc.bugzilla at aptsketch dot com
2014-02-18  9:04 ` [Bug c++/60258] " jakub at gcc dot gnu.org
2014-02-18 11:30 ` ja.gcc.bugzilla at aptsketch dot com
2014-02-18 11:34 ` jakub at gcc dot gnu.org
2014-02-18 20:06 ` daniel.kruegler at googlemail dot com
2014-02-19  7:58 ` daniel.kruegler at googlemail dot com
2014-11-18 16:20 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).