You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by "D. J. Hagberg" <dh...@central.sun.com> on 2002/09/12 22:34:27 UTC

[PATCH] compile fs-test.c with non-gcc compiler

* fs-test.c
  (check_related) File failed compilation with Sun/Forte cc compiler 
  due to struct assignment.  This fix changes pr1 and pr2 to be
  assigned as pointers and dereferenced as pointers.  SunPro cc 
  doesn't seem to follow the convention of bitwise copies of 
  structs on assignments.  The exact error message is:
"subversion/tests/libsvn_fs/fs-test.c", line 5170: left operand must be modifiable lvalue: op "="
"subversion/tests/libsvn_fs/fs-test.c", line 5171: left operand must be modifiable lvalue: op "="
cc: acomp failed for subversion/tests/libsvn_fs/fs-test.c
make: *** [subversion/tests/libsvn_fs/fs-test.o] Error 2


Index: subversion/tests/libsvn_fs/fs-test.c
===================================================================
--- subversion/tests/libsvn_fs/fs-test.c
+++ subversion/tests/libsvn_fs/fs-test.c	Mon Sep  9 13:38:01 2002
@@ -5167,18 +5167,18 @@
       {
         for (j = 0; j < 16; j++)
           {
-            struct path_rev_t pr1 = path_revs[i];
-            struct path_rev_t pr2 = path_revs[j];
+            struct path_rev_t *pr1 = &(path_revs[i]);
+            struct path_rev_t *pr2 = &(path_revs[j]);
             const svn_fs_id_t *id1, *id2;
             int related = 0;
 
             /* Get the ID for the first path/revision combination. */
-            SVN_ERR (svn_fs_revision_root (&rev_root, fs, pr1.rev, pool));
-            SVN_ERR (svn_fs_node_id (&id1, rev_root, pr1.path, pool));
+            SVN_ERR (svn_fs_revision_root (&rev_root, fs, pr1->rev, pool));
+            SVN_ERR (svn_fs_node_id (&id1, rev_root, pr1->path, pool));
           
             /* Get the ID for the second path/revision combination. */
-            SVN_ERR (svn_fs_revision_root (&rev_root, fs, pr2.rev, pool));
-            SVN_ERR (svn_fs_node_id (&id2, rev_root, pr2.path, pool));
+            SVN_ERR (svn_fs_revision_root (&rev_root, fs, pr2->rev, pool));
+            SVN_ERR (svn_fs_node_id (&id2, rev_root, pr2->path, pool));
             
             /* <exciting> Now, run the relationship check! </exciting> */
             related = svn_fs_check_related (id1, id2);
@@ -5191,14 +5191,14 @@
                 return svn_error_createf
                   (SVN_ERR_TEST_FAILED, 0, NULL, pool,
                    "expected `%s:%d' to be related to `%s:%d'; it was not",
-                   pr1.path, (int)pr1.rev, pr2.path, (int)pr2.rev);
+                   pr1->path, (int)pr1->rev, pr2->path, (int)pr2->rev);
               }
             else if ((! related) && related_matrix[i][j])
               {
                 return svn_error_createf
                   (SVN_ERR_TEST_FAILED, 0, NULL, pool,
                    "expected `%s:%d' to not be related to `%s:%d'; it was",
-                   pr1.path, (int)pr1.rev, pr2.path, (int)pr2.rev);
+                   pr1->path, (int)pr1->rev, pr2->path, (int)pr2->rev);
               }
 
             svn_pool_clear (subpool);


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] compile fs-test.c with non-gcc compiler

Posted by Justin Erenkrantz <je...@apache.org>.
On Thu, Sep 12, 2002 at 11:59:35PM +0100, Philip Martin wrote:
> "D. J. Hagberg" <dh...@central.sun.com> writes:
> 
> > Index: subversion/tests/libsvn_fs/fs-test.c
> > ===================================================================
> > --- subversion/tests/libsvn_fs/fs-test.c
> > +++ subversion/tests/libsvn_fs/fs-test.c	Mon Sep  9 13:38:01 2002
> > @@ -5167,18 +5167,18 @@
> >        {
> >          for (j = 0; j < 16; j++)
> >            {
> > -            struct path_rev_t pr1 = path_revs[i];
> > -            struct path_rev_t pr2 = path_revs[j];
> > +            struct path_rev_t *pr1 = &(path_revs[i]);
> > +            struct path_rev_t *pr2 = &(path_revs[j]);
> 
> Out of interest, does using const
> 
> > +            const struct path_rev_t pr1 = path_revs[i];
> > +            const struct path_rev_t pr2 = path_revs[j];
> 
> work?

Nope.

What does work is removing the const from the rev field in
path_rev_t.  I'll commit that and if anyone has anything better,
let me know first and I'll try it out with forte.  It doesn't
seem to produce a warning with gcc (on Darwin), and it's a much
easier solution than D.J.'s original suggestion.

For more on non-modifiable lvalues:

http://www.embedded.com/story/OEG20010618S0075

Based on my reading of that, it seems that forte *is* correct on
producing this warning.  But, I could be wrong and we need to submit
a bug report to Sun.

Non-compilable code is a sure way to make me not happy.  -- justin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] compile fs-test.c with non-gcc compiler

Posted by Philip Martin <ph...@codematters.co.uk>.
"D. J. Hagberg" <dh...@central.sun.com> writes:

> Index: subversion/tests/libsvn_fs/fs-test.c
> ===================================================================
> --- subversion/tests/libsvn_fs/fs-test.c
> +++ subversion/tests/libsvn_fs/fs-test.c	Mon Sep  9 13:38:01 2002
> @@ -5167,18 +5167,18 @@
>        {
>          for (j = 0; j < 16; j++)
>            {
> -            struct path_rev_t pr1 = path_revs[i];
> -            struct path_rev_t pr2 = path_revs[j];
> +            struct path_rev_t *pr1 = &(path_revs[i]);
> +            struct path_rev_t *pr2 = &(path_revs[j]);

Out of interest, does using const

> +            const struct path_rev_t pr1 = path_revs[i];
> +            const struct path_rev_t pr2 = path_revs[j];

work?

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] compile fs-test.c with non-gcc compiler

Posted by Branko Čibej <br...@xbc.nu>.
D. J. Hagberg wrote:

>* fs-test.c
>  (check_related) File failed compilation with Sun/Forte cc compiler 
>  due to struct assignment.  This fix changes pr1 and pr2 to be
>  assigned as pointers and dereferenced as pointers.  SunPro cc 
>  doesn't seem to follow the convention of bitwise copies of 
>  structs on assignments.
>
It's not a convention, it's a standard feature of ISO C. Witness that 
even HP's notoriously quirky C complier handles that code without 
complaints.

Are you sure there are no optiions that would modify the behaviour of 
Sun's cc to accept that code?

-- 
Brane Čibej   <br...@xbc.nu>   http://www.xbc.nu/brane/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org