public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/56465] New: Strange warning about variable modified range
@ 2013-02-26 17:20 ktietz at gcc dot gnu.org
  2013-02-26 17:23 ` [Bug c/56465] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ktietz at gcc dot gnu.org @ 2013-02-26 17:20 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56465
           Summary: Strange warning about variable modified range
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ktietz@gcc.gnu.org


The following code produces warning, but it is actual a constant.

typedef __SIZE_TYPE__ size_t;

char _buf[(size_t) ((char *) 0 + sizeof (size_t))];

t_arr.c:3:1: Warnung: variabel modifiziertes »_buf« im Dateibereich
[standardmäßig aktiviert]
 char _buf[(size_t) ((char *) 0 + sizeof (size_t))];
 ^


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

* [Bug c/56465] Strange warning about variable modified range
  2013-02-26 17:20 [Bug c/56465] New: Strange warning about variable modified range ktietz at gcc dot gnu.org
@ 2013-02-26 17:23 ` pinskia at gcc dot gnu.org
  2013-02-28 15:56 ` ktietz at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-02-26 17:23 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-02-26 17:23:21 UTC ---
>it is actual a constant.

I don't think it is a integer constant expression though as it contains a cast
from a pointer type to an integer type.


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

* [Bug c/56465] Strange warning about variable modified range
  2013-02-26 17:20 [Bug c/56465] New: Strange warning about variable modified range ktietz at gcc dot gnu.org
  2013-02-26 17:23 ` [Bug c/56465] " pinskia at gcc dot gnu.org
@ 2013-02-28 15:56 ` ktietz at gcc dot gnu.org
  2013-02-28 17:19 ` jasonwucj at gmail dot com
  2014-10-23 18:25 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ktietz at gcc dot gnu.org @ 2013-02-28 15:56 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Kai Tietz <ktietz at gcc dot gnu.org> 2013-02-28 15:56:09 UTC ---
(In reply to comment #1)
> >it is actual a constant.
> 
> I don't think it is a integer constant expression though as it contains a cast
> from a pointer type to an integer type.

Well, it isn't a integer scalar, but still a constant.


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

* [Bug c/56465] Strange warning about variable modified range
  2013-02-26 17:20 [Bug c/56465] New: Strange warning about variable modified range ktietz at gcc dot gnu.org
  2013-02-26 17:23 ` [Bug c/56465] " pinskia at gcc dot gnu.org
  2013-02-28 15:56 ` ktietz at gcc dot gnu.org
@ 2013-02-28 17:19 ` jasonwucj at gmail dot com
  2014-10-23 18:25 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jasonwucj at gmail dot com @ 2013-02-28 17:19 UTC (permalink / raw)
  To: gcc-bugs


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

Chung-Ju Wu <jasonwucj at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jasonwucj at gmail dot com

--- Comment #3 from Chung-Ju Wu <jasonwucj at gmail dot com> 2013-02-28 17:19:13 UTC ---
(In reply to comment #2)
> (In reply to comment #1)
> > >it is actual a constant.
> > 
> > I don't think it is a integer constant expression though as it contains a cast
> > from a pointer type to an integer type.
> 
> Well, it isn't a integer scalar, but still a constant.

To my understanding, it is not a constant.

For example, 

  int i;
  i = (int) ((int*)0 + 1);

Could you tell the value of i from C language point of view?

According to C99 6.5.6 Point 8, 
"When an expression that has integer type is added to or subtracted
 from a pointer, the result has the type of the pointer operand."

Hence, the result of "(int*)0 + 1" is a 'pointer to type T'.
So, no, you can't tell the value.
It depends on integer size of target machine.


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

* [Bug c/56465] Strange warning about variable modified range
  2013-02-26 17:20 [Bug c/56465] New: Strange warning about variable modified range ktietz at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-02-28 17:19 ` jasonwucj at gmail dot com
@ 2014-10-23 18:25 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-10-23 18:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think the warning is correct here; the array size is not an integer constant
expression, only something that's been folded to a constant.


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

end of thread, other threads:[~2014-10-23 18:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-26 17:20 [Bug c/56465] New: Strange warning about variable modified range ktietz at gcc dot gnu.org
2013-02-26 17:23 ` [Bug c/56465] " pinskia at gcc dot gnu.org
2013-02-28 15:56 ` ktietz at gcc dot gnu.org
2013-02-28 17:19 ` jasonwucj at gmail dot com
2014-10-23 18:25 ` 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).