public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39462] check assert() at compile time if possible
       [not found] <bug-39462-4@http.gcc.gnu.org/bugzilla/>
@ 2011-09-29  0:05 ` paolo.carlini at oracle dot com
  2012-01-08 21:52 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-29  0:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|gcc-bugs at gcc dot gnu.org |
         Resolution|                            |INVALID

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-29 00:00:28 UTC ---
I guess we can as well close this.


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

* [Bug c++/39462] check assert() at compile time if possible
       [not found] <bug-39462-4@http.gcc.gnu.org/bugzilla/>
  2011-09-29  0:05 ` [Bug c++/39462] check assert() at compile time if possible paolo.carlini at oracle dot com
@ 2012-01-08 21:52 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-08 21:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-08 21:51:17 UTC ---
(In reply to comment #4)
> Also - I admit not having studied in detail all your requirements, sorry about
> that - I suppose you would be interested in static_assert, available with
> -std=c++0x, in gcc4.3.x (and 4.4.x, of course):
> 
>   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html

And static assert is now part of C11 standard. And can be used in 4.7 and above
with _Static_assert keyword.


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

* [Bug c++/39462] check assert() at compile time if possible
  2009-03-14 17:18 [Bug c++/39462] New: " ich at az2000 dot de
                   ` (5 preceding siblings ...)
  2009-03-15  0:32 ` paolo dot carlini at oracle dot com
@ 2009-03-15  0:59 ` ich at az2000 dot de
  6 siblings, 0 replies; 9+ messages in thread
From: ich at az2000 dot de @ 2009-03-15  0:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from ich at az2000 dot de  2009-03-15 00:58 -------
Hm yea, I thought already about that. But I cannot think of a good (and easy)
definition when an assert() should be checked at compile time and whether not.
And thus, I am not sure if that is something which belongs into the C++
standard itself.

That is why I thought it would be the best to let the compiler do such a check
if possible (and that pretty much depends on the cleverness of the compiler)
and to just accept the situation that there could be cases where the value
could be known in theory already at compile time but the compiler doesn't catch
that.

static asserts are different again (and I don't think there are of no use).
There is a common intersection between what I want and what static asserts
would offer but this intersection is small and they will not really solve the
issue that it would be still very nice if the compiler could check asserts at
compile time if possible (and in that case, I think that static asserts are
only of little use; but it's of course hard to tell that, also because if not
all compiler supports compile-time checks on asserts, a lot of people will use
static asserts as a semi-alternative).

But I could also just be wrong with these thoughts. I am not really into the
GCC development and even after about 5 years of C++ development, I still see
more and more new and different ways of doing stuff in C++.


-- 


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


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

* [Bug c++/39462] check assert() at compile time if possible
  2009-03-14 17:18 [Bug c++/39462] New: " ich at az2000 dot de
                   ` (4 preceding siblings ...)
  2009-03-15  0:10 ` ich at az2000 dot de
@ 2009-03-15  0:32 ` paolo dot carlini at oracle dot com
  2009-03-15  0:59 ` ich at az2000 dot de
  6 siblings, 0 replies; 9+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-03-15  0:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo dot carlini at oracle dot com  2009-03-15 00:31 -------
Hey, no problem really, just wanted to let you aware that the next Standard
will deliver an assert checked at compile time. In general, if you want
something special for the next releases of the C++ Standard, I would suggest
making sure people in the appropriate places hear your voice. In general, we
(GCC Project) are mostly interested in features already standardized or
designed with that in mind.


-- 


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


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

* [Bug c++/39462] check assert() at compile time if possible
  2009-03-14 17:18 [Bug c++/39462] New: " ich at az2000 dot de
                   ` (3 preceding siblings ...)
  2009-03-14 23:41 ` paolo dot carlini at oracle dot com
@ 2009-03-15  0:10 ` ich at az2000 dot de
  2009-03-15  0:32 ` paolo dot carlini at oracle dot com
  2009-03-15  0:59 ` ich at az2000 dot de
  6 siblings, 0 replies; 9+ messages in thread
From: ich at az2000 dot de @ 2009-03-15  0:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from ich at az2000 dot de  2009-03-15 00:10 -------
(In reply to comment #4)
> Also - I admit not having studied in detail all your requirements, sorry about
> that - I suppose you would be interested in static_assert, available with
> -std=c++0x, in gcc4.3.x (and 4.4.x, of course):
> 
>   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html
> 

Thanks, but static_assert is not an option. It would make things only more
complicated and can not cover a lot of cases.

I also don't really understand why there is something like a static_assert (I
am not sure how much I really would use an assert outside of a function). If a
compiler would be intelligent enough to check asserts at compile time if
possible, to differ between static_assert and assert only makes it more
complicated - mostly for the programmer.


-- 


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


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

* [Bug c++/39462] check assert() at compile time if possible
  2009-03-14 17:18 [Bug c++/39462] New: " ich at az2000 dot de
                   ` (2 preceding siblings ...)
  2009-03-14 20:25 ` rguenth at gcc dot gnu dot org
@ 2009-03-14 23:41 ` paolo dot carlini at oracle dot com
  2009-03-15  0:10 ` ich at az2000 dot de
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-03-14 23:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo dot carlini at oracle dot com  2009-03-14 23:41 -------
Also - I admit not having studied in detail all your requirements, sorry about
that - I suppose you would be interested in static_assert, available with
-std=c++0x, in gcc4.3.x (and 4.4.x, of course):

  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html


-- 


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


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

* [Bug c++/39462] check assert() at compile time if possible
  2009-03-14 17:18 [Bug c++/39462] New: " ich at az2000 dot de
  2009-03-14 17:33 ` [Bug c++/39462] " rguenth at gcc dot gnu dot org
  2009-03-14 19:48 ` ich at az2000 dot de
@ 2009-03-14 20:25 ` rguenth at gcc dot gnu dot org
  2009-03-14 23:41 ` paolo dot carlini at oracle dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-03-14 20:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2009-03-14 20:25 -------
The attribute is new in GCC 4.3.


-- 


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


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

* [Bug c++/39462] check assert() at compile time if possible
  2009-03-14 17:18 [Bug c++/39462] New: " ich at az2000 dot de
  2009-03-14 17:33 ` [Bug c++/39462] " rguenth at gcc dot gnu dot org
@ 2009-03-14 19:48 ` ich at az2000 dot de
  2009-03-14 20:25 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: ich at az2000 dot de @ 2009-03-14 19:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ich at az2000 dot de  2009-03-14 19:48 -------
Really thanks a lot for that hint.

I did a small assert-implementation by my own:
http://openlierox.svn.sourceforge.net/viewvc/openlierox/include/cassert?view=markup

Btw., it seems that Apples GCC (even 4.2) does not support that attribute. Any
alternative? But I guess you (GCC devs) are not responsible for that.


-- 


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


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

* [Bug c++/39462] check assert() at compile time if possible
  2009-03-14 17:18 [Bug c++/39462] New: " ich at az2000 dot de
@ 2009-03-14 17:33 ` rguenth at gcc dot gnu dot org
  2009-03-14 19:48 ` ich at az2000 dot de
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-03-14 17:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-03-14 17:33 -------
You should be able to do this already with something like

void do_the_warning (void) __attribute__((warning("assertion always false")));

#define assert(X) \
if (__builtin_constant_p (X) \
    && !(X))                  \
  do_the_warning ();          \
if (!(X)) abort ();


-- 


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


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

end of thread, other threads:[~2012-01-08 21:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-39462-4@http.gcc.gnu.org/bugzilla/>
2011-09-29  0:05 ` [Bug c++/39462] check assert() at compile time if possible paolo.carlini at oracle dot com
2012-01-08 21:52 ` pinskia at gcc dot gnu.org
2009-03-14 17:18 [Bug c++/39462] New: " ich at az2000 dot de
2009-03-14 17:33 ` [Bug c++/39462] " rguenth at gcc dot gnu dot org
2009-03-14 19:48 ` ich at az2000 dot de
2009-03-14 20:25 ` rguenth at gcc dot gnu dot org
2009-03-14 23:41 ` paolo dot carlini at oracle dot com
2009-03-15  0:10 ` ich at az2000 dot de
2009-03-15  0:32 ` paolo dot carlini at oracle dot com
2009-03-15  0:59 ` ich at az2000 dot de

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