public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52521] New: [C++11] user defined literals and order of declaration
@ 2012-03-07 14:00 marc.glisse at normalesup dot org
  2012-03-07 14:59 ` [Bug c++/52521] " jakub at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: marc.glisse at normalesup dot org @ 2012-03-07 14:00 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52521
           Summary: [C++11] user defined literals and order of declaration
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: marc.glisse@normalesup.org


#include <cstdlib>
int operator "" _w(const char*);
int operator "" _w(const char*, std::size_t);
int main() {
  123_w;
}

a.cc: In function 'int main()':
a.cc:5:3: error: unable to find numeric literal operator 'operator"" _w'

The problem disappears if I switch the 2 declarations...

Btw, mangling these operators like functions called li_w taking the same
arguments is strange, I could have such a function in my code.


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
@ 2012-03-07 14:59 ` jakub at gcc dot gnu.org
  2012-03-07 20:10 ` jason at gcc dot gnu.org
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-07 14:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-03-07
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org
   Target Milestone|---                         |4.7.0
     Ever Confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-07 14:58:21 UTC ---
The only mail I found about the mangling was
http://communities.mentor.com/community/cs/archives/cxx-abi-dev/msg02351.html
but the ABI document at least on the web hasn't been updated.
If li is the operator name, then I'd think instead of
_Z4li_wPKc
we should mangle it as
_Zli2_wPKc
- i.e. "li" followed by <length,ID> pair would be <operator-name> (and have
support for this in the demangler).
Jason, can this be resolved on cxx-abi-dev and for 4.7.0-RC2?  Sounds like a
blocker to me for 4.7.0, releasing udlit support which is mangled incorrectly
would be very bad, especially when it clashes with user function.s


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
  2012-03-07 14:59 ` [Bug c++/52521] " jakub at gcc dot gnu.org
@ 2012-03-07 20:10 ` jason at gcc dot gnu.org
  2012-03-07 20:17 ` jason at gcc dot gnu.org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2012-03-07 20:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
  2012-03-07 14:59 ` [Bug c++/52521] " jakub at gcc dot gnu.org
  2012-03-07 20:10 ` jason at gcc dot gnu.org
@ 2012-03-07 20:17 ` jason at gcc dot gnu.org
  2012-03-07 20:20 ` jason at gcc dot gnu.org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2012-03-07 20:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2012-03-07 20:16:48 UTC ---
Author: jason
Date: Wed Mar  7 20:16:16 2012
New Revision: 185077

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185077
Log:
    PR c++/52521
    * mangle.c (write_literal_operator_name): The length comes after the
    operator prefix.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/udlit-mangle.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/mangle.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (2 preceding siblings ...)
  2012-03-07 20:17 ` jason at gcc dot gnu.org
@ 2012-03-07 20:20 ` jason at gcc dot gnu.org
  2012-03-09 21:21 ` jakub at gcc dot gnu.org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2012-03-07 20:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2012-03-07 20:20:09 UTC ---
Author: jason
Date: Wed Mar  7 20:20:00 2012
New Revision: 185079

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185079
Log:
    PR c++/52521
    * mangle.c (write_literal_operator_name): The length comes after the
    operator prefix.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/udlit-mangle.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/mangle.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (3 preceding siblings ...)
  2012-03-07 20:20 ` jason at gcc dot gnu.org
@ 2012-03-09 21:21 ` jakub at gcc dot gnu.org
  2012-03-14  8:48 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-09 21:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-09 21:21:15 UTC ---
Created attachment 26869
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26869
gcc48-pr52521.patch

If ignoring possibility of parameters with default arguments, I guess the fix
could look like this.  If operator"" could have default arguments, it would
complicate things a little bit.
[over.literal]/3 lists what argument types are allowed, so IMHO it isn't
possible to have say
int operator"" _w (long double, long double = 2.0L);, but what if there is
say
int operator"" _w (const char *, std::size_t = 0);
?  Can it be called for int i = 123_w; ?  Though, [over.literal]/4 says that
a raw literal operator contains a single const char * argument and
[lex.ext]/{3,4} says that a raw literal operator is called for integer/floating
udlits, so perhaps it shouldn't call int operator"" _w (const char *,
std::size_t = 0); and the attached patch is sufficient.

Jason, what do you think?


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (4 preceding siblings ...)
  2012-03-09 21:21 ` jakub at gcc dot gnu.org
@ 2012-03-14  8:48 ` jakub at gcc dot gnu.org
  2012-03-16 19:29 ` andy at aligature dot com
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-14  8:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-14 08:30:45 UTC ---
Author: jakub
Date: Wed Mar 14 08:30:23 2012
New Revision: 185375

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185375
Log:
    PR c++/52521
    * parser.c (lookup_literal_operator): Return fn only if
    processed all arguments from args vector and argtypes is
    void_list_node.

    * g++.dg/cpp0x/udlit-args2.C: New test.

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


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (5 preceding siblings ...)
  2012-03-14  8:48 ` jakub at gcc dot gnu.org
@ 2012-03-16 19:29 ` andy at aligature dot com
  2012-03-16 20:08 ` marc.glisse at normalesup dot org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: andy at aligature dot com @ 2012-03-16 19:29 UTC (permalink / raw)
  To: gcc-bugs

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

Andy Webber <andy at aligature dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andy at aligature dot com

--- Comment #6 from Andy Webber <andy at aligature dot com> 2012-03-16 19:23:18 UTC ---
I've been playing around with a gcc 4.7.0 RC2 build and it seems like the user
defined literals might not be working at all now.

Building:
#include <iostream>
#include <cstdlib>

constexpr long double operator"" _degrees(long double d)
{
   return d * 0.0175;
}

int main()
{
   long double pi = 180_degrees;
   std::cout << pi << std::endl;
}

Result:
literal.cpp: In function ‘int main()’:
literal.cpp:11:21: error: unable to find numeric literal operator ‘operator""
_degrees’


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (6 preceding siblings ...)
  2012-03-16 19:29 ` andy at aligature dot com
@ 2012-03-16 20:08 ` marc.glisse at normalesup dot org
  2012-03-16 20:18 ` andy at aligature dot com
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: marc.glisse at normalesup dot org @ 2012-03-16 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Marc Glisse <marc.glisse at normalesup dot org> 2012-03-16 19:39:14 UTC ---
(In reply to comment #6)
> constexpr long double operator"" _degrees(long double d)
> {
>    return d * 0.0175;
> }
> 
> int main()
> {
>    long double pi = 180_degrees;
>    std::cout << pi << std::endl;
> }

There is no dot in 180, so it is looking for an unsigned long long overload
(which you could provide). 180._degrees works.


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (7 preceding siblings ...)
  2012-03-16 20:08 ` marc.glisse at normalesup dot org
@ 2012-03-16 20:18 ` andy at aligature dot com
  2012-03-16 20:53 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: andy at aligature dot com @ 2012-03-16 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andy Webber <andy at aligature dot com> 2012-03-16 20:06:52 UTC ---
Ah, that fixes it.  It could be good to update the release notes to match.

Thanks to Ed Smith-Rowland, G++ now implements C++11 user-defined literals.
// Not actually a good approximation.  :)
constexpr long double operator"" _degrees (long double d) { return d * 0.0175;
}
long double pi = 180_degrees;

long double pi = 180.0_degrees;


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (8 preceding siblings ...)
  2012-03-16 20:18 ` andy at aligature dot com
@ 2012-03-16 20:53 ` jakub at gcc dot gnu.org
  2012-03-16 21:04 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-16 20:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-16 20:50:14 UTC ---
What in the release notes should be updated?

The standard says that for 180_degrees the compiler should try to call
operator "" _degrees (180ULL)
(if operator "" _degrees (unsigned long long) exists), or
operator "" _degrees ("180")
(if operator "" _degrees (const char *) exists), or
operator "" _degrees <'1', '8', '0'> ()
(if literal operator template exists).

So your testcase is invalid.


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (9 preceding siblings ...)
  2012-03-16 20:53 ` jakub at gcc dot gnu.org
@ 2012-03-16 21:04 ` jakub at gcc dot gnu.org
  2012-03-22  8:31 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-16 21:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-16 20:52:47 UTC ---
Ah, sorry, you're right, fixed up gcc-4.7/changes.html.


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (10 preceding siblings ...)
  2012-03-16 21:04 ` jakub at gcc dot gnu.org
@ 2012-03-22  8:31 ` rguenth at gcc dot gnu.org
  2012-03-22  9:56 ` marc.glisse at normalesup dot org
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-22  8:31 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.0                       |4.7.1

--- Comment #11 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-22 08:26:14 UTC ---
GCC 4.7.0 is being released, adjusting target milestone.


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (11 preceding siblings ...)
  2012-03-22  8:31 ` rguenth at gcc dot gnu.org
@ 2012-03-22  9:56 ` marc.glisse at normalesup dot org
  2012-03-22 10:15 ` jakub at gcc dot gnu.org
  2012-03-22 10:20 ` jakub at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: marc.glisse at normalesup dot org @ 2012-03-22  9:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Marc Glisse <marc.glisse at normalesup dot org> 2012-03-22 09:42:43 UTC ---
(In reply to comment #11)
> GCC 4.7.0 is being released, adjusting target milestone.

I think it is already fixed, actually.
(not closing with this message to leave someone a chance to contradict me)


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (12 preceding siblings ...)
  2012-03-22  9:56 ` marc.glisse at normalesup dot org
@ 2012-03-22 10:15 ` jakub at gcc dot gnu.org
  2012-03-22 10:20 ` jakub at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-22 10:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-22 10:10:29 UTC ---
Author: jakub
Date: Thu Mar 22 10:10:24 2012
New Revision: 185683

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185683
Log:
    Backported from mainline
    2012-03-14  Jakub Jelinek  <jakub@redhat.com>

    PR c++/52521
    * parser.c (lookup_literal_operator): Return fn only if
    processed all arguments from args vector and argtypes is
    void_list_node.

    * g++.dg/cpp0x/udlit-args2.C: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/udlit-args2.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/parser.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/52521] [C++11] user defined literals and order of declaration
  2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
                   ` (13 preceding siblings ...)
  2012-03-22 10:15 ` jakub at gcc dot gnu.org
@ 2012-03-22 10:20 ` jakub at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-22 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-22 10:14:39 UTC ---
The mangling was fixed already for 4.7.0, the rest is fixed now for 4.7.1+.


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

end of thread, other threads:[~2012-03-22 10:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-07 14:00 [Bug c++/52521] New: [C++11] user defined literals and order of declaration marc.glisse at normalesup dot org
2012-03-07 14:59 ` [Bug c++/52521] " jakub at gcc dot gnu.org
2012-03-07 20:10 ` jason at gcc dot gnu.org
2012-03-07 20:17 ` jason at gcc dot gnu.org
2012-03-07 20:20 ` jason at gcc dot gnu.org
2012-03-09 21:21 ` jakub at gcc dot gnu.org
2012-03-14  8:48 ` jakub at gcc dot gnu.org
2012-03-16 19:29 ` andy at aligature dot com
2012-03-16 20:08 ` marc.glisse at normalesup dot org
2012-03-16 20:18 ` andy at aligature dot com
2012-03-16 20:53 ` jakub at gcc dot gnu.org
2012-03-16 21:04 ` jakub at gcc dot gnu.org
2012-03-22  8:31 ` rguenth at gcc dot gnu.org
2012-03-22  9:56 ` marc.glisse at normalesup dot org
2012-03-22 10:15 ` jakub at gcc dot gnu.org
2012-03-22 10:20 ` jakub 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).