public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/55749] New: gcc 4.7.1 removes labels mistakenly
@ 2012-12-20  4:21 blue_3too at hotmail dot com
  2012-12-20  5:32 ` [Bug c/55749] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: blue_3too at hotmail dot com @ 2012-12-20  4:21 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55749
           Summary: gcc 4.7.1 removes labels mistakenly
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: blue_3too@hotmail.com


gcc version 4.7.1 (GCC) x86_64-unknown-linux-gnu

in the following small c program, label-as-value always incorrectly uses the
begining of the function (.e. pointer p is always set to the begining of foo).
Turning of scheduling will generate the correct code.

Is this a known bug? any pointer will be appreciated. thanks
>cat m.c

void *p;
extern void bar();
void foo()
{
    p = &&my_label;
    bar();

my_label:

    bar();
}

> gcc -O2 -S m.c

> less m.s

       .globl  foo
        .type   foo, @function
foo:
.LFB0:
.L2:
        subq    $8, %rsp
.LCFI0:
        xorl    %eax, %eax
        movq    $.L2, p(%rip)
        call    bar
        xorl    %eax, %eax
        addq    $8, %rsp
.LCFI1:
        jmp     bar
.LFE0:
        .size   foo, .-foo
        .comm   p,8,8
        .comm   i,4,4


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

* [Bug c/55749] gcc 4.7.1 removes labels mistakenly
  2012-12-20  4:21 [Bug c/55749] New: gcc 4.7.1 removes labels mistakenly blue_3too at hotmail dot com
@ 2012-12-20  5:32 ` pinskia at gcc dot gnu.org
  2012-12-20 16:17 ` blue_3too at hotmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-12-20  5:32 UTC (permalink / raw)
  To: gcc-bugs


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-20 05:31:56 UTC ---
This is not a bug as you don't use labels-as-a-value with a computed goto.  You
need a computed goto to use label correctly so since you don't have one, GCC
assumes you are never jumping to that label and moves it around.


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

* [Bug c/55749] gcc 4.7.1 removes labels mistakenly
  2012-12-20  4:21 [Bug c/55749] New: gcc 4.7.1 removes labels mistakenly blue_3too at hotmail dot com
  2012-12-20  5:32 ` [Bug c/55749] " pinskia at gcc dot gnu.org
@ 2012-12-20 16:17 ` blue_3too at hotmail dot com
  2012-12-20 16:18 ` blue_3too at hotmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: blue_3too at hotmail dot com @ 2012-12-20 16:17 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from blue_3too at hotmail dot com 2012-12-20 16:17:20 UTC ---
Thanks for the comments. I checked the document @
gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html . But find no description hat
label-as-a-value should be used with computed goto.  Can you be more specific
about where is the decription from?

But back to my problem: my_labe is a resuming point for a thread to acquire a
lock after being blocked on the lock and slept. When it is waken, it should
resume execution from my_label. So I guess it conradicts with following
description in the doc:
"You may not use this mechanism to jump to code in a different function. If you
do that, totally unpredictable things happen. The best way to avoid this is to
store the label address only in automatic variables and never pass it as an
argument. "

Because the label is passed out of the function, it is used to jump back the
function when the sleeping thread is awaken. Now


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

* [Bug c/55749] gcc 4.7.1 removes labels mistakenly
  2012-12-20  4:21 [Bug c/55749] New: gcc 4.7.1 removes labels mistakenly blue_3too at hotmail dot com
  2012-12-20  5:32 ` [Bug c/55749] " pinskia at gcc dot gnu.org
  2012-12-20 16:17 ` blue_3too at hotmail dot com
@ 2012-12-20 16:18 ` blue_3too at hotmail dot com
  2012-12-20 16:55 ` pinskia at gcc dot gnu.org
  2024-03-16 17:57 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: blue_3too at hotmail dot com @ 2012-12-20 16:18 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from blue_3too at hotmail dot com 2012-12-20 16:18:23 UTC ---
Thanks for the comments. I checked the document @
gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html . But find no description hat
label-as-a-value should be used with computed goto.  Can you be more specific
about where is the description from?

But back to my problem: my_labe is a resuming point for a thread to acquire a
lock after being blocked on the lock and slept. When it is waken, it should
resume execution from my_label. So I guess it contradicts with following
description in the doc:
"You may not use this mechanism to jump to code in a different function. If you
do that, totally unpredictable things happen. The best way to avoid this is to
store the label address only in automatic variables and never pass it as an
argument. "

Because the label is passed out of the function, it is used to jump back the
function when the sleeping thread is awaken. Not sure how to implement this
properly.


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

* [Bug c/55749] gcc 4.7.1 removes labels mistakenly
  2012-12-20  4:21 [Bug c/55749] New: gcc 4.7.1 removes labels mistakenly blue_3too at hotmail dot com
                   ` (2 preceding siblings ...)
  2012-12-20 16:18 ` blue_3too at hotmail dot com
@ 2012-12-20 16:55 ` pinskia at gcc dot gnu.org
  2024-03-16 17:57 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-12-20 16:55 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-20 16:54:53 UTC ---
"To use these values, you need to be able to jump to one. This is done with the
computed goto statement1, goto *exp;."

> Not sure how to implement this properly.

Use either setjmp/longjmp or getcontext/setcontext/makecontext instead.


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

* [Bug c/55749] gcc 4.7.1 removes labels mistakenly
  2012-12-20  4:21 [Bug c/55749] New: gcc 4.7.1 removes labels mistakenly blue_3too at hotmail dot com
                   ` (3 preceding siblings ...)
  2012-12-20 16:55 ` pinskia at gcc dot gnu.org
@ 2024-03-16 17:57 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-16 17:57 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |DUPLICATE

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
.

*** This bug has been marked as a duplicate of bug 44298 ***

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

end of thread, other threads:[~2024-03-16 17:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-20  4:21 [Bug c/55749] New: gcc 4.7.1 removes labels mistakenly blue_3too at hotmail dot com
2012-12-20  5:32 ` [Bug c/55749] " pinskia at gcc dot gnu.org
2012-12-20 16:17 ` blue_3too at hotmail dot com
2012-12-20 16:18 ` blue_3too at hotmail dot com
2012-12-20 16:55 ` pinskia at gcc dot gnu.org
2024-03-16 17:57 ` pinskia 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).