public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/20426] New: error: initializer element is not constant
@ 2005-03-11 13:12 pluto at pld-linux dot org
  2005-03-11 13:28 ` [Bug other/20426] " falk at debian dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pluto at pld-linux dot org @ 2005-03-11 13:12 UTC (permalink / raw)
  To: gcc-bugs

# test.c
static const unsigned major = 0;
static const unsigned minor = 9;
static const unsigned build = 1;
const unsigned version = (major << 24) | (minor << 16) | build;

# gcc -c test.c
test.c:4: error: initializer element is not constant

Hmm, which initializer isn't constant? Do I missed something?

-- 
           Summary: error: initializer element is not constant
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pluto at pld-linux dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-linux
  GCC host triplet: i686-linux
GCC target triplet: i686-linux


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


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

* [Bug other/20426] error: initializer element is not constant
  2005-03-11 13:12 [Bug other/20426] New: error: initializer element is not constant pluto at pld-linux dot org
@ 2005-03-11 13:28 ` falk at debian dot org
  2005-03-11 14:07 ` pinskia at gcc dot gnu dot org
  2005-03-11 14:20 ` pluto at pld-linux dot org
  2 siblings, 0 replies; 4+ messages in thread
From: falk at debian dot org @ 2005-03-11 13:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2005-03-11 13:28 -------
(In reply to comment #0)
> # test.c
> static const unsigned major = 0;
> static const unsigned minor = 9;
> static const unsigned build = 1;
> const unsigned version = (major << 24) | (minor << 16) | build;
> 
> # gcc -c test.c
> test.c:4: error: initializer element is not constant
> 
> Hmm, which initializer isn't constant? Do I missed something?

"major", for example, is not a constant expression. It might not make a lot
of sense, but that's the way the C standard defines it.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug other/20426] error: initializer element is not constant
  2005-03-11 13:12 [Bug other/20426] New: error: initializer element is not constant pluto at pld-linux dot org
  2005-03-11 13:28 ` [Bug other/20426] " falk at debian dot org
@ 2005-03-11 14:07 ` pinskia at gcc dot gnu dot org
  2005-03-11 14:20 ` pluto at pld-linux dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-11 14:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-11 14:06 -------
Note in C++ they will be constants though but not in C.  C has different rules for constant expressions 
than C++.

-- 


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


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

* [Bug other/20426] error: initializer element is not constant
  2005-03-11 13:12 [Bug other/20426] New: error: initializer element is not constant pluto at pld-linux dot org
  2005-03-11 13:28 ` [Bug other/20426] " falk at debian dot org
  2005-03-11 14:07 ` pinskia at gcc dot gnu dot org
@ 2005-03-11 14:20 ` pluto at pld-linux dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pluto at pld-linux dot org @ 2005-03-11 14:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pluto at pld-linux dot org  2005-03-11 14:19 -------
(In reply to comment #2)
> Note in C++ they will be constants though but not in C.  C has different rules
for constant expressions 
> than C++.

Thanks for explain. I have one more basic question.
Why the non-static symbol isn't exported from C++ module?
In C only static symbols aren't exported. What about C++?

[ cat ver.cpp ]
static const unsigned major = 0;
static const unsigned minor = 9;
static const unsigned build = 1;
const unsigned version = (major << 24) | (minor << 16) | build;

[ ver.s ]
.file   "ver.cpp"
.ident  "GCC: (GNU) 4.0.0 20050305 (prerelease) (PLD Linux)"
.section        .note.GNU-stack,"",@progbits


-- 


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


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

end of thread, other threads:[~2005-03-11 14:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-11 13:12 [Bug other/20426] New: error: initializer element is not constant pluto at pld-linux dot org
2005-03-11 13:28 ` [Bug other/20426] " falk at debian dot org
2005-03-11 14:07 ` pinskia at gcc dot gnu dot org
2005-03-11 14:20 ` pluto at pld-linux dot 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).