public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/62024] New: __atomic_always_lock_free is not a constant expression
@ 2014-08-05 12:48 amanieu at gmail dot com
  2014-08-13  5:22 ` [Bug c/62024] " mpolacek at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: amanieu at gmail dot com @ 2014-08-05 12:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 62024
           Summary: __atomic_always_lock_free is not a constant expression
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amanieu at gmail dot com

This line causes an error despite the documentation saying that
__atomic_always_lock_free is a constant expression:

_Static_assert(__atomic_always_lock_free(sizeof(int), 0), "");

test.c:1:16: error: expression in static assertion is not constant


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

* [Bug c/62024] __atomic_always_lock_free is not a constant expression
  2014-08-05 12:48 [Bug c/62024] New: __atomic_always_lock_free is not a constant expression amanieu at gmail dot com
@ 2014-08-13  5:22 ` mpolacek at gcc dot gnu.org
  2014-08-13  5:43 ` amanieu at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-08-13  5:22 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-08-13
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |4.10.0
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed even for C++.  The issue is the same: fold folds
__atomic_always_lock_free to 1, but that 1 is wrapped in NOP_EXPR - and static
assert code is unhappy.  I think we can just STRIP_TYPE_NOPS - we don't expect
an lvalue in the static assert code.  I'm testing a patch for that.

Not a regression.


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

* [Bug c/62024] __atomic_always_lock_free is not a constant expression
  2014-08-05 12:48 [Bug c/62024] New: __atomic_always_lock_free is not a constant expression amanieu at gmail dot com
  2014-08-13  5:22 ` [Bug c/62024] " mpolacek at gcc dot gnu.org
@ 2014-08-13  5:43 ` amanieu at gmail dot com
  2014-08-13 16:27 ` joseph at codesourcery dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: amanieu at gmail dot com @ 2014-08-13  5:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Amanieu d'Antras <amanieu at gmail dot com> ---
A similar error happens when trying to use the result of
__atomic_always_lock_free as the size of an array:

int array[__atomic_always_lock_free(sizeof(int), 0)];

test.c:1:5: error: variably modified ‘array’ at file scope
>From gcc-bugs-return-458320-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Aug 13 06:07:52 2014
Return-Path: <gcc-bugs-return-458320-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 17656 invoked by alias); 13 Aug 2014 06:07:51 -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 17602 invoked by uid 48); 13 Aug 2014 06:07:45 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/62024] __atomic_always_lock_free is not a constant expression
Date: Wed, 13 Aug 2014 06:07: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.9.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mpolacek 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: 4.10.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-62024-4-zjqDGblx3A@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62024-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62024-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-08/txt/msg00817.txt.bz2
Content-length: 667

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Amanieu d'Antras from comment #2)
> int array[__atomic_always_lock_free(sizeof(int), 0)];
> 
> test.c:1:5: error: variably modified ‘array’ at file scope

I think it should be fine to reject this one - the array size is not an integer
constant expression.  While the first argument of _Static_assert also has to be
an integer constant expression, I thought we could permit some latitude here; 
the _Static_assert (__atomic_always_lock_free (sizeof (int), 0), "foo"); line
looks quite reasonable to me...
>From gcc-bugs-return-458321-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Aug 13 06:41:38 2014
Return-Path: <gcc-bugs-return-458321-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 32578 invoked by alias); 13 Aug 2014 06:41:37 -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 32531 invoked by uid 48); 13 Aug 2014 06:41:28 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/62059] signed integer overflow in diagnostic.c adjust_line
Date: Wed, 13 Aug 2014 06:41: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.9.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: minor
X-Bugzilla-Who: mpolacek 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 cc everconfirmed
Message-ID: <bug-62059-4-ceDmHfuGhB@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62059-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62059-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-08/txt/msg00818.txt.bz2
Content-length: 560

https://gcc.gnu.org/bugzilla/show_bug.cgi?idb059

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-08-13
                 CC|                            |mpolacek at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.


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

* [Bug c/62024] __atomic_always_lock_free is not a constant expression
  2014-08-05 12:48 [Bug c/62024] New: __atomic_always_lock_free is not a constant expression amanieu at gmail dot com
  2014-08-13  5:22 ` [Bug c/62024] " mpolacek at gcc dot gnu.org
  2014-08-13  5:43 ` amanieu at gmail dot com
@ 2014-08-13 16:27 ` joseph at codesourcery dot com
  2014-08-14 15:00 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: joseph at codesourcery dot com @ 2014-08-13 16:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
Whatever we do for __atomic_always_lock_free, note that we'll probably 
need to find some way for ATOMIC_*_LOCK_FREE (in stdatomic.h) to expand 
to something usable in #if.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_458.htm


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

* [Bug c/62024] __atomic_always_lock_free is not a constant expression
  2014-08-05 12:48 [Bug c/62024] New: __atomic_always_lock_free is not a constant expression amanieu at gmail dot com
                   ` (2 preceding siblings ...)
  2014-08-13 16:27 ` joseph at codesourcery dot com
@ 2014-08-14 15:00 ` mpolacek at gcc dot gnu.org
  2014-08-14 17:00 ` joseph at codesourcery dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-08-14 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to joseph@codesourcery.com from comment #4)
> Whatever we do for __atomic_always_lock_free, note that we'll probably 
> need to find some way for ATOMIC_*_LOCK_FREE (in stdatomic.h) to expand 
> to something usable in #if.
> 
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_458.htm

Couldn't we just map ATOMIC_*_LOCK_FREE macros (in stdatomic.h) to
__GCC_ATOMIC_*_LOCK_FREE macros defined in c-cppbuiltin.c:cpp_atomic_builtins?
FWIW, libsupc++ does exactly that.  If this approach makes sense, I can prepare
a patch with testcase(s).


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

* [Bug c/62024] __atomic_always_lock_free is not a constant expression
  2014-08-05 12:48 [Bug c/62024] New: __atomic_always_lock_free is not a constant expression amanieu at gmail dot com
                   ` (3 preceding siblings ...)
  2014-08-14 15:00 ` mpolacek at gcc dot gnu.org
@ 2014-08-14 17:00 ` joseph at codesourcery dot com
  2014-08-25 11:52 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: joseph at codesourcery dot com @ 2014-08-14 17:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Thu, 14 Aug 2014, mpolacek at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62024
> 
> --- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
> (In reply to joseph@codesourcery.com from comment #4)
> > Whatever we do for __atomic_always_lock_free, note that we'll probably 
> > need to find some way for ATOMIC_*_LOCK_FREE (in stdatomic.h) to expand 
> > to something usable in #if.
> > 
> > http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_458.htm
> 
> Couldn't we just map ATOMIC_*_LOCK_FREE macros (in stdatomic.h) to
> __GCC_ATOMIC_*_LOCK_FREE macros defined in c-cppbuiltin.c:cpp_atomic_builtins?
> FWIW, libsupc++ does exactly that.  If this approach makes sense, I can prepare
> a patch with testcase(s).

Yes, I think that should work.


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

* [Bug c/62024] __atomic_always_lock_free is not a constant expression
  2014-08-05 12:48 [Bug c/62024] New: __atomic_always_lock_free is not a constant expression amanieu at gmail dot com
                   ` (4 preceding siblings ...)
  2014-08-14 17:00 ` joseph at codesourcery dot com
@ 2014-08-25 11:52 ` mpolacek at gcc dot gnu.org
  2014-09-03 11:17 ` mpolacek at gcc dot gnu.org
  2014-09-03 11:18 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-08-25 11:52 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I posted a patch.  Let's see what happens.


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

* [Bug c/62024] __atomic_always_lock_free is not a constant expression
  2014-08-05 12:48 [Bug c/62024] New: __atomic_always_lock_free is not a constant expression amanieu at gmail dot com
                   ` (5 preceding siblings ...)
  2014-08-25 11:52 ` mpolacek at gcc dot gnu.org
@ 2014-09-03 11:17 ` mpolacek at gcc dot gnu.org
  2014-09-03 11:18 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-09-03 11:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Wed Sep  3 11:16:29 2014
New Revision: 214871

URL: https://gcc.gnu.org/viewcvs?rev=214871&root=gcc&view=rev
Log:
    PR c/62024
    * c-parser.c (c_parser_static_assert_declaration_no_semi): Strip no-op
    conversions.

    * g++.dg/cpp0x/pr62024.C: New test.
    * gcc.dg/pr62024.c: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr62024.C
    trunk/gcc/testsuite/gcc.dg/pr62024.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-parser.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c/62024] __atomic_always_lock_free is not a constant expression
  2014-08-05 12:48 [Bug c/62024] New: __atomic_always_lock_free is not a constant expression amanieu at gmail dot com
                   ` (6 preceding siblings ...)
  2014-09-03 11:17 ` mpolacek at gcc dot gnu.org
@ 2014-09-03 11:18 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-09-03 11:18 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Should be fixed.


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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-05 12:48 [Bug c/62024] New: __atomic_always_lock_free is not a constant expression amanieu at gmail dot com
2014-08-13  5:22 ` [Bug c/62024] " mpolacek at gcc dot gnu.org
2014-08-13  5:43 ` amanieu at gmail dot com
2014-08-13 16:27 ` joseph at codesourcery dot com
2014-08-14 15:00 ` mpolacek at gcc dot gnu.org
2014-08-14 17:00 ` joseph at codesourcery dot com
2014-08-25 11:52 ` mpolacek at gcc dot gnu.org
2014-09-03 11:17 ` mpolacek at gcc dot gnu.org
2014-09-03 11:18 ` mpolacek at gcc dot gnu.org

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).