Bug 258465

Summary: chinese/c2t: fix build with clang 13
Product: Ports & Packages Reporter: Dimitry Andric <dim>
Component: Individual Port(s)Assignee: Dimitry Andric <dim>
Status: Closed FIXED    
Severity: Affects Some People CC: fernape
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
chinese/c2t: fix "error: address of register variable requested" none

Description Dimitry Andric freebsd_committer freebsd_triage 2021-09-12 20:51:54 UTC
During an exp-run for llvm 13 (see bug 258209), it turned out that chinese/c2t fails to build with clang 13:

cc -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -DCHINDICT=\"/usr/local/share/chinese/gb/TONEPY.tit\" -c c2t.c
c2t.c:99:3: error: address of register variable requested
  hz[2] = '\0';
  ^~
c2t.c:107:7: error: address of register variable requested
      hz[0] = (char)eka;
      ^~
c2t.c:108:7: error: address of register variable requested
      hz[1] = (char)toka;
      ^~
c2t.c:113:8: error: address of register variable requested
          if (hz[0] != (*pipo)[i] || hz[1] != (*pipo)[i+1]) continue;
              ^~
c2t.c:113:31: error: address of register variable requested
          if (hz[0] != (*pipo)[i] || hz[1] != (*pipo)[i+1]) continue;
                                     ^~
c2t.c:133:36: error: address of register variable requested
                fprintf(miss_chars, "%c", hz[0]);
                                          ^~
c2t.c:134:30: error: address of register variable requested
                fprintf(miss_chars, "%c ", hz[1]);
                                           ^~
c2t.c:143:17: error: address of register variable requested
                        printf("%c", hz[0]);
                                     ^~
c2t.c:144:18: error: address of register variable requested
                        printf("%c ", hz[1]);
                                      ^~
9 errors generated.

As indicated, arrays shouldn't be register variables as they don't have addresses. In general, the register keyword is deprecated and should no longer be used.

To fix this, use a command line flag to define "register" to empty.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2021-09-12 20:52:32 UTC
Created attachment 227863 [details]
chinese/c2t: fix "error: address of register variable requested"
Comment 2 Fernando ApesteguĂ­a freebsd_committer freebsd_triage 2021-09-16 05:57:34 UTC
^Triage: Reporter is committer, assign accordingly.
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-10-02 11:23:46 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0efce95397d4b53be14448a803902191ab8c1df3

commit 0efce95397d4b53be14448a803902191ab8c1df3
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-09-12 20:48:25 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-10-02 11:19:56 +0000

    chinese/c2t: fix "error: address of register variable requested"

    During an exp-run for llvm 13 (see bug 258209), it turned out that
    chinese/c2t fails to build with clang 13:

    cc -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -DCHINDICT=\"/usr/local/share/chinese/gb/TONEPY.tit\" -c c2t.c
    c2t.c:99:3: error: address of register variable requested
      hz[2] = '\0';
      ^~
    c2t.c:107:7: error: address of register variable requested
          hz[0] = (char)eka;
          ^~
    c2t.c:108:7: error: address of register variable requested
          hz[1] = (char)toka;
          ^~
    c2t.c:113:8: error: address of register variable requested
              if (hz[0] != (*pipo)[i] || hz[1] != (*pipo)[i+1]) continue;
                  ^~
    c2t.c:113:31: error: address of register variable requested
              if (hz[0] != (*pipo)[i] || hz[1] != (*pipo)[i+1]) continue;
                                         ^~
    c2t.c:133:36: error: address of register variable requested
                    fprintf(miss_chars, "%c", hz[0]);
                                              ^~
    c2t.c:134:30: error: address of register variable requested
                    fprintf(miss_chars, "%c ", hz[1]);
                                               ^~
    c2t.c:143:17: error: address of register variable requested
                            printf("%c", hz[0]);
                                         ^~
    c2t.c:144:18: error: address of register variable requested
                            printf("%c ", hz[1]);
                                          ^~
    9 errors generated.

    As indicated, arrays shouldn't be register variables as they don't have
    addresses. In general, the register keyword is deprecated and should no
    longer be used.

    To fix this, use a command line flag to define "register" to empty.

    PR:             258465
    Approved by:    maintainer timeout (2 weeks)
    MFH:            2021Q4

 chinese/c2t/Makefile | 2 ++
 1 file changed, 2 insertions(+)