public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/56086] New: when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined
@ 2013-01-23 19:26 rjarrett at mathworks dot com
  2013-01-23 20:48 ` [Bug c/56086] " joseph at codesourcery dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rjarrett at mathworks dot com @ 2013-01-23 19:26 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56086
           Summary: when compiling C code with -std=gnu99 macro
                    __STDC_UTF_16__ is defined
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rjarrett@mathworks.com


Created attachment 29255
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29255
sample program

The macro __STDC_UTF_16__ is unexpectedly defined  when compiling  C code using
gcc 4.7.2 (also present in gcc 4.7.1)

This is a regression from gcc 4.5.3. (also gcc 4.4.6)

compilation line:
gcc -c -std=gnu99 gcc47_stdc_utf_16.c 

expected result: no output

actual result:
gcc47_stdc_utf_16.c:3:2: warning: #warning __STDC_UTF_16__ defined [-Wcpp]


use case was in a header file used for both C and C++ compilation that
contained
#if defined(__STDC_UTF_16__)
...
#endif

workaround:
use :#if (__cplusplus && defined(__STDC_UTF_16__)) in place of


#if defined(__STDC_UTF_16__)


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

* [Bug c/56086] when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined
  2013-01-23 19:26 [Bug c/56086] New: when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined rjarrett at mathworks dot com
@ 2013-01-23 20:48 ` joseph at codesourcery dot com
  2013-01-27 16:12 ` rjarrett at mathworks dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: joseph at codesourcery dot com @ 2013-01-23 20:48 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2013-01-23 20:47:49 UTC ---
Why do you think this is a bug?  GCC meets the semantics of that macro 
(that char16_t values are UTF-16 encoded), and gnu99 mode enables u"" 
strings.


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

* [Bug c/56086] when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined
  2013-01-23 19:26 [Bug c/56086] New: when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined rjarrett at mathworks dot com
  2013-01-23 20:48 ` [Bug c/56086] " joseph at codesourcery dot com
@ 2013-01-27 16:12 ` rjarrett at mathworks dot com
  2013-01-27 16:14 ` rjarrett at mathworks dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rjarrett at mathworks dot com @ 2013-01-27 16:12 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Roger Jarrett <rjarrett at mathworks dot com> 2013-01-27 16:12:09 UTC ---
Created attachment 29285
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29285
example program to compile


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

* [Bug c/56086] when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined
  2013-01-23 19:26 [Bug c/56086] New: when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined rjarrett at mathworks dot com
  2013-01-23 20:48 ` [Bug c/56086] " joseph at codesourcery dot com
  2013-01-27 16:12 ` rjarrett at mathworks dot com
@ 2013-01-27 16:14 ` rjarrett at mathworks dot com
  2013-01-28  3:43 ` joseph at codesourcery dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rjarrett at mathworks dot com @ 2013-01-27 16:14 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Roger Jarrett <rjarrett at mathworks dot com> 2013-01-27 16:13:48 UTC ---
The macro __STDC_UTF_16__ is being used to guard the following typedef
typedef char16_t CHAR16_T;

compiling the program  (attached program t2.c)
typedef char16_t fred;
int main() {

}

with gcc 4.7.1 or 4.7.2 results in a compilation error: gcc -std=gnu99 t2.c
t2.c:1:1: error: unknown type name 'char16_t'


However, it succeeds as expected when compiled with g++ -std=c++11 t2.c

What am I missing here ?
--Roger


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

* [Bug c/56086] when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined
  2013-01-23 19:26 [Bug c/56086] New: when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined rjarrett at mathworks dot com
                   ` (2 preceding siblings ...)
  2013-01-27 16:14 ` rjarrett at mathworks dot com
@ 2013-01-28  3:43 ` joseph at codesourcery dot com
  2013-01-28  8:29 ` jakub at gcc dot gnu.org
  2013-01-29 17:43 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: joseph at codesourcery dot com @ 2013-01-28  3:43 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2013-01-28 03:43:31 UTC ---
For C, char16_t and char32_t are typedefs in <uchar.h> (a header provided 
by the C library, not by GCC), *not* built-in types, and __STDC_UTF_16__ 
is a built-in macro.

For C++, char16_t and char32_t are built-in types that don't need a header 
to use them, and __STDC_UTF_16__ is defined in <cuchar> rather than 
built-in (I don't know if any change may have resulted from Jason raising 
the issue of the difference from C regarding that macro as per 
<http://gcc.gnu.org/ml/gcc-patches/2011-08/msg01524.html>).


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

* [Bug c/56086] when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined
  2013-01-23 19:26 [Bug c/56086] New: when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined rjarrett at mathworks dot com
                   ` (3 preceding siblings ...)
  2013-01-28  3:43 ` joseph at codesourcery dot com
@ 2013-01-28  8:29 ` jakub at gcc dot gnu.org
  2013-01-29 17:43 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-01-28  8:29 UTC (permalink / raw)
  To: gcc-bugs


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

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

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-28 08:28:40 UTC ---
Let's CC Jason on this.


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

* [Bug c/56086] when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined
  2013-01-23 19:26 [Bug c/56086] New: when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined rjarrett at mathworks dot com
                   ` (4 preceding siblings ...)
  2013-01-28  8:29 ` jakub at gcc dot gnu.org
@ 2013-01-29 17:43 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2013-01-29 17:43 UTC (permalink / raw)
  To: gcc-bugs


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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2013-01-29 17:43:23 UTC ---
(In reply to comment #3)
> The macro __STDC_UTF_16__ is being used to guard the following typedef
> typedef char16_t CHAR16_T;

This doesn't work.  The macro does not indicate that char16_t is declared;
rather, it indicates that values of char16_t are UTF-16 encoded.  The compiler
is following the standard.


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

end of thread, other threads:[~2013-01-29 17:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-23 19:26 [Bug c/56086] New: when compiling C code with -std=gnu99 macro __STDC_UTF_16__ is defined rjarrett at mathworks dot com
2013-01-23 20:48 ` [Bug c/56086] " joseph at codesourcery dot com
2013-01-27 16:12 ` rjarrett at mathworks dot com
2013-01-27 16:14 ` rjarrett at mathworks dot com
2013-01-28  3:43 ` joseph at codesourcery dot com
2013-01-28  8:29 ` jakub at gcc dot gnu.org
2013-01-29 17:43 ` jason 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).